// Start producers and consumers
int numProducers = 2;
int numConsumers = 2;
ProdCons2 pc = new ProdCons2(numProducers, numConsumers);
// Let it run for, say, 30 seconds
Thread.sleep(30*1000);
// End of simulation - shut down gracefully
synchronized(pc.list) {
pc.done = true;
pc.list.notifyAll(); // Wake up any waiters!
}