网站介绍:文章浏览阅读137次。懒汉式:太懒了,等到需要的时候才加载。这个不是线程安全的,所以一般用的极少:public class Singleton{ private static Singleton singleton; public static Singleton getInstance(){ if(singleton == null){ singleton = new Singleton(); } return singleton; }}这个是线程安全的,但是synchronized粒度较大_手写 dcl
- 链接地址:https://blog.csdn.net/weixin_44959377/article/details/106890531
- 链接标题:手写单例模式_手写 dcl-CSDN博客
- 所属网站:blog.csdn.net
- 被收藏次数:9833
- 网站标签:手写 dcl