Exemplo n.º 1
0
 public static ChocolateBoilerInfo GetInstance()
 {
     if (_uniqueInstance == null)
     {
         lock (objLock)
         {
             if (_uniqueInstance == null)
             {
                 _uniqueInstance = new ChocolateBoilerInfo();
                 Console.WriteLine("Create a ChocolateBoiler");
             }
         }
     }
     return(_uniqueInstance);
 }
        static void Main(string[] args)
        {
            ChocolateBoilerInfo boiler1 = ChocolateBoilerInfo.GetInstance();

            Console.WriteLine("--== boiler1 ==--");
            boiler1.Fill();
            boiler1.Boil();
            boiler1.Drain();
            Console.WriteLine();

            ChocolateBoilerInfo boiler2 = ChocolateBoilerInfo.GetInstance();

            Console.WriteLine("--== boiler2 ==--");
            boiler2.Fill();
            boiler2.Boil();
            boiler2.Drain();

            Console.ReadLine();
        }