예제 #1
0
 static void Main(string[] args)
 {
     if (SingleTon.GetSingleTon() == SingleTon.GetSingleTon())
     {
         System.Console.WriteLine("Same instance");
     }
 }
예제 #2
0
 public static SingleTon GetSingleTon()
 {
     if (instance == null)
     {
         lock (syncLock)
         {
             if (instance == null)
             {
                 instance = new SingleTon();
             }
         }
     }
     return(instance);
 }