Esempio n. 1
0
 public static Sun GetInstance()
 {
     if (_instance == null)
     {
         lock (locker)
         {
             _instance = new Sun();
         }
     }
     return(_instance);
 }
Esempio n. 2
0
        public static void MainProgram()
        {
            var sun    = Sun.GetInstance();
            var newSun = Sun.GetInstance();

            if (sun == newSun)
            {
                Console.WriteLine("Shit, we have two similar suns!");
            }

            var moon    = Moon.GetInstance();
            var newMoon = Moon.GetInstance();

            if (moon == newMoon)
            {
                Console.WriteLine("Shit, we have two similar moons! Their radius is {0}", Moon.GetInstance().Size);
            }
        }