from http://www.dotblogs.com.tw/pin0513/archive/2010/03/08/13931.aspx

 1: public class Singleton{

   2:     //透用一個靜態變數記錄實體
   3:     private static Singleton uniqueInstance;
   4:     //建構式的啦
   5:     private Singleton(){}
   6:     public static Singleton getInstance(){
   7:         if (uniqueInstance == null)
   8:             uniqueInstance = new Singleton();
   9:         return uniqueInstance;
  10:     }
  11: }