package com.itheima;
/**
* 6、 编写一个延迟加载的单例设计模式。
*
* @author Myth丶骞
*
*/
public class Test6 {
static class Singleton {
private static Singleton s = null;
private Singleton() {
}
public static Singleton getInstance() {
if (s == null) {
synchronized (s) {
if (s == null)
s = new Singleton();
}
}
return s;
}
}
} |
|