public static void Main()
        {
            Queue <int> queue      = new Queue <int>();
            SyncEvents  syncEvents = new SyncEvents();

            Console.WriteLine("Configurando los hilos...");
            Producer producer       = new Producer(queue, syncEvents);
            Consumer consumer       = new Consumer(queue, syncEvents);
            Thread   producerThread = new Thread(producer.ThreadRun);
            Thread   consumerThread = new Thread(consumer.ThreadRun);

            Console.WriteLine("Inician productor consumidor");
            producerThread.Start();
            consumerThread.Start();

            for (int i = 0; i < 4; i++)
            {
                Thread.Sleep(2500);
                ShowQueueContents(queue);
            }
            Console.WriteLine("señal de final de hilo...");
            syncEvents.ExitThreadEvent.Set();
            producerThread.Join();
            consumerThread.Join();
            Console.ReadKey(true);
        }
 public Consumer(Queue <int> q, SyncEvents e)
 {
     _queue      = q;
     _syncEvents = e;
 }
 public Producer(Queue <int> q, SyncEvents e)
 {
     _queue      = q;
     _syncEvents = e;
 }