Ejemplo n.º 1
0
        // the producer class PRODUCETOBUFFER Creates a new instance of productionitem, Locks on the key objects
        public static void ProduceToBuffer()
        {
            ProductionItem pi = new ProductionItem();

            Thread.Sleep(1000);
            Monitor.TryEnter(Program.zeKey);
            {
                ProductionBuffer.Bufferclass(pi);
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 2
0
 public static void Bufferclass(ProductionItem pi)
 {
     if (PrBuffer.Count <= 4)
     {
         PrBuffer.Enqueue(pi);
         Console.WriteLine("Producer created an item {0}", PrBuffer.Count);
     }
     else
     {
         Console.WriteLine("Productions Buffer is full");
     }
 }