예제 #1
0
 public static ChocolateBoiler getInstance()
 {
     if (uniqueInstancep == null)
     {
         uniqueInstancep = new ChocolateBoiler();
     }
     return(uniqueInstancep);
 }
예제 #2
0
        public static ChocolateBoiler getInstance()
        {
            if (uniqueInstancep == null)
            {
                uniqueInstancep = new ChocolateBoiler();

            }
            return uniqueInstancep;
        }
예제 #3
0
            public static ChocolateBoiler GetInstance()
            {
                if (ChocolateBoilerUniqueInstance == null)
                {
                    ChocolateBoilerUniqueInstance = new ChocolateBoiler();
                }

                return(ChocolateBoilerUniqueInstance);
            }
예제 #4
0
        static void Main(string[] args)
        {
            ChocolateBoiler boiler1 = ChocolateBoiler.GetInstance();
            ChocolateBoiler boiler2 = ChocolateBoiler.GetInstance();

            boiler1.Fill();
            boiler2.Boil();
            boiler1.Drain();

            Console.Read();
        }
예제 #5
0
        static void Main(string[] args)
        {
            ChocolateBoiler chocolateBoiler = ChocolateBoiler.GetInstance();

            chocolateBoiler.Fill();
            ChocolateBoiler anotherChocolateBoiler = ChocolateBoiler.GetInstance();

            anotherChocolateBoiler.Drain();
            chocolateBoiler.Boil();
            chocolateBoiler.Drain();
            Console.ReadKey();
        }
예제 #6
0
 private static void Main()
 {
     try
     {
         var chocoEggs = ChocolateBoiler.GetInstance();
         chocoEggs.Fill();
         chocoEggs.Boil();
         chocoEggs.Drain();
     }
     catch (Exception)
     {
         Console.Write("Oops");
     }
 }
예제 #7
0
 public static ChocolateBoiler GetInstance()
 {
     lock (Lock)
     {
         if (_singleton == null)
         {
             _singleton = new ChocolateBoiler();
             return(_singleton);
         }
         else
         {
             throw new Exception();
         }
     }
 }
        public static ChocolateBoiler GetInstance()
        {
            if (uniqueInstance == null)
            {
                lock (syncRoot)
                {
                    if (uniqueInstance == null)
                    {
                        uniqueInstance = new ChocolateBoiler();
                    }
                }
            }

            return(uniqueInstance);
        }
예제 #9
0
 static void Main(string[] args)
 {
     ChocolateBoiler.getInstance().fill();
     ChocolateBoiler.getInstance().boil();
     ChocolateBoiler.getInstance().drain();
 }