In the producer-consumer problem, there is one producer that is producing something and there is a consumer that is consuming the products produced by the producer. The producer and consumer share the same memory buffer that is of fixed size.
The producer's job is to generate the data, put it into the buffer, and again start generating data, while the consumer's job is to consume the data from the buffer.
Your task is to ensure that the producer won't try to add data to the buffer if it's full and that the consumer won't try to remove data from an empty buffer. To that end, you will implement the class Buffer, which represents the buffer you are trying to synchronize. The size of the Buffer class in this problem will be limited to 1.
There are also two threads called Consumer and Producer.
Producer will generate data and try to put it in the Buffer by calling its put() method.
Consumer will consume the data stored in Buffer by calling its get() method.