单例模式实现的几种方式
饿汉式、线程安全、最简单的方式
public class S1_HungerImplement {
private static final S1_HungerImplement INSTANCE = new S1_HungerImplement();
private S1_HungerImplement() {
}
public static S1_HungerImplement getInstance() {
return INSTANCE;
}
}
懒汉式、非线程安全、最简单的方式
public class S2_LazyLoadingImplement {
private static S2_LazyLoadingImplement INSTANCE;
private S2_LazyLoadingImplement() {
}
public static S2_LazyLoadingImplement getInstance() {
if (INSTANCE == null) {
INSTANCE = new S2_LazyLoadingImplement(