singleton.java
来自「深入浅出设计模式」· Java 代码 · 共 24 行
JAVA
24 行
package headfirst.singleton.dcl;//// Danger! This implementation of Singleton not// guaranteed to work prior to Java 5//public class Singleton { private volatile static Singleton uniqueInstance; private Singleton() {} public static Singleton getInstance() { if (uniqueInstance == null) { synchronized (Singleton.class) { if (uniqueInstance == null) { uniqueInstance = new Singleton(); } } } return uniqueInstance; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?