完美单例模式
单例模式的各种概念网上有很多,这里直接贴代码:
//classholder
public class Singleton {
private Singleton(){}
private static class SingletonHolder(){
private static final Singleton INSTANCE = new Singleton();
}
public static final Singleton getInstance(){
return SingletonHolder.INSTANCE;
}
}
网友评论