public class Singleton {
private static Singleton instance;
private static Object syncRoot = new Object();
private Singleton() {}
public static Singleton getInstance(){
if(instance == null){
synchronized (syncRoot) {
if(instance == null){
instance = new Singleton();
}
}
}
return instance;
}
线程安全下的单例类 ,双重锁定哦