如题
Java中单例模式的使用有很多方法
1.懒汉式,饿汉式,等等
用到哪个整理哪个
懒汉式
饿汉式
双检查
private static CameraPhotographPresenter sInstance;
private CameraPhotographPresenter(){
}
public static CameraPhotographPresenter getInstance() {
if(sInstance==null){
synchronized (CameraPhotographPresenter.class){
if(sInstance==null){
sInstance = new CameraPhotographPresenter();
}
}
}
return sInstance;
}
标签:CameraPhotographPresenter,单例,private,static,模式,饿汉,sInstance From: https://www.cnblogs.com/baidurenshen/p/17762303.html