先贴代码
class Procum {
private volatile int product = 0;
public synchronized void product() throws InterruptedException {
while (product != 0) {
wait();
}
product++;
System.out.println("生产了第" + product + "件货物");
notifyAll();
}
public synchronized void consumer