public class Singleton{
private static Singleton sInstance = null;
private Singleton(){
}
public static Singleton getInstance(){
if(sInstance == null){
synchronized(Singleton.class){
if(sInstance == null){
sInstance = new Singleton();
}
}
}
return sInstance;
}
}
原文:https://blog.51cto.com/williamnw/2540402