Beispiel #1
0
        private static void StartBoil()
        {
            SingletonChocolateBoiler boiler = SingletonChocolateBoiler.GetTheOnlyAndOneBoiler();

            if (!boiler.IsFull())
            {
                for (int i = 0; i < SingletonChocolateBoiler.CHOCOLATE_CAPACITY; i++)
                {
                    boiler.Fill(1);
                }
            }
            boiler.Boil();
        }
Beispiel #2
0
        public static SingletonChocolateBoiler GetTheOnlyAndOneBoiler()
        {
            if (_chocolateBoiler == null)
            {
                lock (syncRoot)
                {
                    if (_chocolateBoiler == null)
                    {
                        _chocolateBoiler = new SingletonChocolateBoiler();
                    }
                }
            }

            return(_chocolateBoiler);
        }