Exemplo n.º 1
0
        //public static int LastElement = -1;

        public Producer(BoundedBuffer buffer, int howMany)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("Buffer is null");
            }
            if (HowMany < 0)
            {
                throw new ArgumentOutOfRangeException("howMany is out of range");
            }
            Buffer  = buffer;
            HowMany = howMany;
        }
Exemplo n.º 2
0
        //public static int LastElement = -1;

        public Producer(BoundedBuffer buffer, int howMany)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("Buffer is null");
            }
            if (HowMany < 0)
            {
                throw new ArgumentOutOfRangeException("howMany is out of range");
            }
            Buffer = buffer;
            HowMany = howMany;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer = new BoundedBuffer(4);
            Producer producer = new Producer(buffer, 10000);
            Consumer consumer = new Consumer(buffer, 10000);
            
            Parallel.Invoke(producer.Run, consumer.Run);



            //Thread t1 = new Thread(() => producer.Run());
            //Thread t2 = new Thread(() => consumer.Run());
            //t1.Start();
            //t2.Start();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            BoundedBuffer buffer   = new BoundedBuffer(4);
            Producer      producer = new Producer(buffer, 10000);
            Consumer      consumer = new Consumer(buffer, 10000);

            Parallel.Invoke(producer.Run, consumer.Run);



            //Thread t1 = new Thread(() => producer.Run());
            //Thread t2 = new Thread(() => consumer.Run());
            //t1.Start();
            //t2.Start();
        }
Exemplo n.º 5
0
 public Consumer(BoundedBuffer buffer, int howMany)
 {
     Buffer = buffer;
     HowMany = howMany;
 }
Exemplo n.º 6
0
 public Consumer(BoundedBuffer buffer, int howMany)
 {
     Buffer  = buffer;
     HowMany = howMany;
 }