Buffer - get method
Buffer - get method
synchronized public Object get() {
while (count==0) {
try {wait();} catch(InterruptedException e){}
}
Object o =buf[out];
buf[out]=null; // for display purposes
--count;
out=(out+1) % size;
notify(); // [count < size]
return (o);
}
The get method waits until there is an item in the buffer. When it has removed an item then it notifies a thread which may be waiting to put an item