线程安全的singleton

    public class Singleton {  
       private Singleton(){}
      
      static class SingletonHolder {  
        static Singleton instance = new Singleton();  
      }  
      
      public static Singleton getInstance() {  
        return SingletonHolder.instance;  
      }  
      
    }  
 

你可能感兴趣的:(Singleton)