如何在java中创建线程安全的singleton
2 回答
白衣染霜花
TA贡献1796条经验 获得超10个赞
1 2 3 4 5 6 7 8 | public class Singleton { private static Singleton instance = null; private Singleton() {} public static synchronized Singleton getInstance(){ if (instance == null) instance = new Singleton(); return instance; } } |
- 2 回答
- 0 关注
- 578 浏览
添加回答
举报
0/150
提交
取消