延迟初始化占位类模式
public class Singleton { private Singleton() {} private static final class Holder{ static final Singleton singleton=new Singleton(); } public static Singleton getInstance() { return Holder.singleton; } }
public class Singleton { private Singleton() {} private static final class Holder{ static final Singleton singleton=new Singleton(); } public static Singleton getInstance() { return Holder.singleton; } }