public class HungurySingleton { //缺点,无法延时加载,没有使用就已经加载了
private static final HungurySingleton mInstance = new HungurySingleton();
private HungurySingleton(){
}
public static HungurySingleton getHunguryInstance(){
return mInstance;
}
}
显然,饿汉式在没有调用时就已经提前加载到了内存中,效率不是很高,无法实现延迟加载。
|
|