//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; }
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(); }
public Consumer(BoundedBuffer buffer, int howMany) { Buffer = buffer; HowMany = howMany; }