乐趣区

关于java:设计模式

懒汉式单例

public class RecommendPresenter {private RecommendPresenter() { }

    private static RecommendPresenter sInstance = null;

    /**
     * 获取单例对象
     * @return
     */
    public static RecommendPresenter getInstance() {if (sInstance == null) {synchronized (RecommendPresenter.class) {if (sInstance == null) {sInstance = new RecommendPresenter();
                }
            }
        }
    }
}
退出移动版