双重检验锁模式
/ * description: 单例DCL设计模式 也就是双重检验锁模式
*/
public class Dclsingleton {
private static volatile Dclsingleton instance = null;
private Dclsingleton() {
}
public static Dclsingleton getInstance() {
//避免不必要的同步
if(instance == null) {
synchronized (Dclsingleton.class) {
if (instance == null) {
instance = new Dclsingleton();
}
}
}
return instance;
}
}