Professional Documents
Culture Documents
Students are requested to implement producer-consumer problems in java and solution for
producer – consumer problem in java.
package javaapplication38;
class Altaf {
int n;
boolean b = false;
if (!b) {
try {
wait();
} catch (Exception e) {
System.out.println(e);
System.out.println("Got:" + n);
b = false;
notify();
return n;
if (b) {
try {
wait();
} catch (Exception e) {
System.out.println(e);
ALTAF CLASSES
this.n = n;
b = true;
System.out.println("Put:" + n);
notify();
Altaf a1;
Thread t1;
producer(Altaf a1) {
this.a1 = a1;
t1 = new Thread(this);
t1.start();
a1.put(i);
Altaf a1;
Thread t1;
consumer(Altaf a1) {
ALTAF CLASSES
this.a1 = a1;
t1 = new Thread(this);
t1.start();
a1.get();
ALTAF CLASSES