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