public static void Main(string[] args) { int length = 10; BoundedBuffer testedBuffer = new BoundedBuffer(length); Producer p1 = new Producer(testedBuffer,15,1); Producer p2 = new Producer(testedBuffer, 15, 2); Consumer c1 = new Consumer(testedBuffer); p2.run(); p1.run(); c1.run(); Thread.Sleep(1000); p1.stop(); p2.stop(); c1.stop(); Console.ReadKey(); }
public Producer(BoundedBuffer buffer, int howMany, int _ID) { if (buffer == null || howMany<1) throw new ArgumentOutOfRangeException("No suitable arguments"); HowMany = howMany; Buffer = buffer; ID = _ID; }
public Consumer(BoundedBuffer buffer) { if (buffer == null) throw new ArgumentNullException("buffer is null"); Buffer = buffer; }