在wikipedia中看到一种单例,效果不错,分享一下。
public class Something {
private Something() {}
private static class LazyHolder {
static final Something INSTANCE = new Something();
}
public static Something getInstance() {
return LazyHolder.INSTANCE;
}
}
参考:
http://ifeve.com/initialization-on-demand-holder-idiom/
标签:LazyHolder,Initialization,private,idiom,static,Something,单例,holder From: https://blog.51cto.com/u_15939105/6003836