本帖最后由 szsycwb 于 2014-5-20 12:54 编辑
- public static synchronized Single getInstance()
- {
- if(instance==null)
- instance=new Single();
- return instance;
- }
复制代码
-------------------------------------------------------------------------------------------------
- public static Single getInstance()
- {
- if(instance==null)
- synchronized(Single.class)
- {
- if(instance==null)
- instance=new Single();
- }
- return instance;
- }
复制代码
效率哪个比较好,有什么区别、 |
|