Source of Singleton.java


  1: 
  2: public class Singleton { 
  3: 
  4:   public static Singleton getInstance() { 
  5:     if (theInstance == null) { 
  6:       theInstance = new Singleton(); 
  7:     }
  8:     return theInstance; 
  9:   }
 10: 
 11:   private Singleton() { 
 12:     // user code
 13:   }
 14: 
 15:   private static Singleton theInstance = null;  
 16: 
 17:   // user code
 18: 
 19: }