class Singleton{ private Singleton(){ } private static volatile Singleton singleton = null; public static Singleton getInstance(){ if (singleton == null){ synchronized (Singleton.class){ if (singleton == null){ singleton = new Singleton(); } } } return singleton; } }
标签:Singleton,singleton,private,static,模式,单例,null From: https://www.cnblogs.com/jixian/p/17175698.html