Java Reference
In-Depth Information
buffet.notify();
}
}
}
}
}
The following ProduceConsumeDemo program instantiates a producer and
consumer thread and starts them. Figure 15.13 shows a sample output.
public class ProduceConsumeDemo
{
public static void main(String [] args)
{
Buffet buffet = new Buffet();
PizzaChef producer = new PizzaChef(buffet);
LunchCrowd consumer = new LunchCrowd(buffet);
producer.start();
consumer.start();
}
}
Figure 15.13 Producer and consumer threads communicate with each other using the
wait() and notify() methods.
Search WWH ::




Custom Search