/**标签:getInstance,静态,private,static,SingleTon06,单例,模式 From: https://www.cnblogs.com/NIAN2011/p/16614616.html
* 单例模式-静态内部类(推荐使用)
* 1.构造私有
* 2.本类定义实例对象
* 3.定义静态内部类
* 4.getInstance()方法公开
*/
public class SingleTon06 {
//2.本类创建静态示例
private static volatile SingleTon06 instance;
//1.构造私有
private SingleTon06() {
}
//3.静态内部类
private static class SingleTonInstance{
private static final SingleTon06 INSTANCE=new SingleTon06();
}
//4.getInstance()方法公开
public static synchronized SingleTon06 getInstance() {
return SingleTonInstance.INSTANCE;
}
}