Exemplo n.º 1
0
        static void Main(string[] args)
        {
            globalHeap = new MinHeap();
            globalProductionFinished = new SharedBool(false);

            Thread t_consumer1 = new Thread(new ThreadStart(C1));
            Thread t_consumer2 = new Thread(new ThreadStart(C2));
            Thread t_producer  = new Thread(new ThreadStart(P));

            // Start threads
            t_consumer1.Start();
            t_consumer2.Start();
            t_producer.Start();

            // Wait for threads to complete
            t_consumer1.Join();
            t_consumer2.Join();
            t_producer.Join();

            Console.Write("\n\nConsumers completed. Press any key...");
            Console.ReadKey();
        }