如何在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 關注
- 621 瀏覽
添加回答
舉報
0/150
提交
取消