静态检测单例模式
调用静态内部类,同样是线程安全的,原理同饿汉式单例
package org.study.singleton;
/**
* 静态检测单例模式
*
*
*/
public class StaticCheckSingleton {
private static class LazyHolder {
private static final StaticCheckSingleton INSTANCE = new StaticCheckSingleton();
}
private StaticCheckSingleton(){};
private static final StaticCheckSingleton getInstance() {
return LazyHolder.INSTANCE;
}
}
程序改变世界