Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            HoldIntegerSynchronized sharedLocation = new HoldIntegerSynchronized();
            Random random = new Random();

            Producer producer = new Producer(sharedLocation, random);
            Consumer consumer = new Consumer(sharedLocation, random);

            Thread thProducer = new Thread(new ThreadStart(producer.Produce));
            Thread thConsumer = new Thread(new ThreadStart(consumer.Consume));

            thProducer.Name = "Producer";
            thConsumer.Name = "Consumer";

            thProducer.Start();
            thConsumer.Start();

            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public Consumer(
     HoldIntegerSynchronized shared, Random random)
 {
     sharedLocation  = shared;
     randomSleepTime = random;
 }