Uses Wait and Pulse to enable producer and consumer threads to cooperate in using a buffer