Beispiel #1
0
        public static Singleton getInstance()
        {
            if (instance == null)
            {
                instance = new Singleton();
            }

            return instance;
        }
 //全局访问instance方法
 public static Singleton GetInstance()
 {
     return instance ?? (instance = new Singleton());//多线程下可能new多次
 }