单例模式

 1 /**   
 2   
 3  * 单例模式创新!google的ioc作者写的。只有在调用的时候才会初始化!而且线程安全   
 4   
 5  * 超级牛!   
 6   
 7  *   
 8   
 9  */    
10     
11 public class Singleton {     
12     
13     static class SingletonHolder {     
14     
15         static Singleton instance = new Singleton();     
16     
17     }     
18     
19     public static Singleton getInstance() {     
20     
21         return SingletonHolder.instance;     
22     
23     }     
24 }    
原文地址:https://www.cnblogs.com/dongye/p/3945407.html