asked 56.7k views
3 votes
Solve a single producer, single consumer problem using wait() and notifyAll(). The producer must not overflow the shared buffer, which can happen if the producer is faster than the consumer. If the consumer is faster than the producer, then it must not read the same data more than once. Do not assume anything about the relative speeds (i.e., random producing and consuming speeds) of the producer or consumer.

1 Answer

4 votes

Step-by-step explanation:

Basically for producer and consumer problem solving for producer using wait () and notify All ()

is if synchronization is o then

{

while (! IsitTrue()) {

o.wait();

}

if o.notify () call appear more than one waiting thread

then return from the o.wait () makes the condition in false state , than other will go back to waiting.

answered
User Andee
by
8.4k points