双重检查锁+Volatile
双层锁 +Volatile
public class Singleto_01 {
private Singleto_01() {
}
//Volatile
private volatile static Singleto_01 s = null;
public static Singleto_01 s1() {
//双层if 判断
if (s == null) {
synchronized (Singleto_01.class){
//双层if 判断
if (s == null){
s = new Singleto_01();
}
}
} else {
}
return s;
}
}