Class: ( ( (Valueset)
Class: ( ( (Valueset)
class Q
int n;
while(!valueSet)
try
wait();
catch(InterruptedException e)
System.out.println("InterruptedException caught");
valueSet = false;
notify();
return n;
while(valueSet)
try
wait();
22x51a3839 22357yfu
catch(InterruptedException e)
System.out.println("InterruptedException caught");
this.n = n;
valueSet = true;
notify();
Q q;
Producer(Q q)
this.q = q;
int i = 0;
while(true)
q.put(i++);
}
22x51a3839 22357yfu
Q q;
Consumer(Q q)
this.q = q;
while(true)
q.get();
class PCFixed
Q q = new Q();
new Producer(q);
new Consumer(q);
}
22x51a3839 22357yfu
OUT PUT: