Exemplo n.º 1
0
        public static Singleton getInstance()
        {
            if (instance == null)
            {
                instance = new Singleton();
            }

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