package src.test.java.com.pbc.singleton;
/**
* (双重加锁懒汉)单例模式
* @author qiu_y
*
*/
public class DoubleLockSingleton {
private static DoubleLockSingleton doubleLockSingleton = null;
/**
* 私有构造器
*/
private DoubleLockSingleton() {}
/**
* 双重加锁懒汉单例
* 懒加载,线程安全,效率高
*/
public static DoubleLockSingleton getInstince() {
if(null == doubleLockSingleton) {
synchronized (DoubleLockSingleton.class) {
if (null == doubleLockSingleton) {
doubleLockSingleton = new DoubleLockSingleton();
}
}
}
return doubleLockSingleton;
}
}
原文:https://www.cnblogs.com/qiuyingbo/p/13231469.html