コード例 #1
0
 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();
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public Consumer(BoundedBuffer buffer)
 {
     if (buffer == null) throw new ArgumentNullException("buffer is null");
     Buffer = buffer;
 }