public class Singleton {
private static volatile Singleton singleton = null;
private Singleton(){}
public static Singleton getSingleton(){
if(singleton == null){
synchronized (Singleton.class){
if(singleton == null){
singleton = new Singleton();
}
}
}
return singleton;
}
}
多线程下单例模式
猜你喜欢
转载自blog.csdn.net/qq_34165535/article/details/81585483
今日推荐
周排行