Example #1
0
        static void Main(string[] args)
        {
            Cell     cell     = new Cell();
            CellCons consumer = new CellCons(cell, 20);
            CellProd producer = new CellProd(cell, 20);

            Thread Tcons = new Thread(new ThreadStart(consumer.consume));
            Thread Tprod = new Thread(new ThreadStart(producer.produce));

            try
            {
                Tcons.Start();
                Tprod.Start();

                Tprod.Join();
                Tcons.Join();
            }
            catch (ThreadStateException ex)
            {
                Console.WriteLine("ThreadStartEx in Main: " + ex.Message);
            }
            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Cell cell = new Cell();
            CellCons consumer = new CellCons(cell, 20);
            CellProd producer = new CellProd(cell, 20);

            Thread Tcons = new Thread(new ThreadStart(consumer.consume));
            Thread Tprod = new Thread(new ThreadStart(producer.produce));
            try
            {
                Tcons.Start();
                Tprod.Start();

                Tprod.Join();
                Tcons.Join();
            }
            catch (ThreadStateException ex)
            {
                Console.WriteLine("ThreadStartEx in Main: " + ex.Message);
            }
            Console.ReadLine();
        }