策码奔腾

延迟初始化占位类模式

public class Singleton {
    private Singleton() {}
    
    private static final class Holder{
        static final Singleton singleton=new Singleton();
    }

    public static Singleton getInstance() {
        return Holder.singleton;
    }
}

 

posted @ 2021-05-18 17:25  策码奔腾  阅读(118)  评论(0编辑  收藏  举报
console.log('欢迎');