static void Main()
        {
            var queue = new SimpleQueue();

            // Consumer class starts three consumer threads
            var consumers = new Consumers(queue, 10);

            // Then we start a producer in a fourth thread
            // Producer produces 30 objects then a null to finish.
            var producer = new Producer(queue, 100);
            var producerThread = new Thread(producer.Produce);
            producerThread.Name = "Producer";
            
            consumers.Start();
            producerThread.Start();
            
            // We wait for the producer to finish - we know it is finite. 
            producerThread.Join();
            // When the producer stops, we signal 
            consumers.Stop();

            Console.WriteLine("Done...");
            Console.ReadLine();
        }
 public Producer(SimpleQueue queue, int max)
 {
     this.queue = queue;
     this.max = max;
 }
 public Consumers(SimpleQueue queue, int count)
 {
     this.queue = queue;
     threads = new Thread[count];
     random = new Random(100);
 }