Exemplo n.º 1
0
 public static SingletonThreadSafe GetInstance(string value)
 {
     if (_instance == null)
     {
         lock (_lock)
         {
             if (_instance == null)
             {
                 _instance       = new SingletonThreadSafe();
                 _instance.Value = value;
             }
         }
     }
     return(_instance);
 }
Exemplo n.º 2
0
        public static void TestSingleton(string value)
        {
            SingletonThreadSafe singleton = SingletonThreadSafe.GetInstance(value);

            Console.WriteLine(singleton.Value);
        }