设计模式
文章目录
懒汉式单例
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();
}
}
}
}
}
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论