public static void Main(string[] args) { int result = 0; Cell cell = new Cell(); Producer producer = new Producer(cell, 5); Consumer consumer = new Consumer(cell, 5); Thread producerThread = new Thread(new ThreadStart(producer.ThreadRun)); Thread consumerThread = new Thread(new ThreadStart(consumer.ThreadRun)); try { producerThread.Start(); consumerThread.Start(); producerThread.Join(); consumerThread.Join(); } catch (ThreadStateException e) { Debug.WriteLine(e); result = 1; } catch (ThreadInterruptedException e) { Debug.WriteLine(e); result = 1; } Environment.ExitCode = result; }
public Producer(Cell box, int request) { _cell = box; _quantity = request; }
public Consumer(Cell box, int request) { _cell = box; _quantity = request; }