public class TestPC {
public static void main(String[] args) {
BufferArea bufferArea = new BufferArea();
new Producer(bufferArea).start(); //生产者
new Consumer(bufferArea).start(); //消费者
}
}
//生产者
class Producer extends Thread{
BufferArea bufferArea;
public Producer(BufferArea bufferArea){
this.bufferArea = bufferArea;
}
//生产
@Override
public void run() {
for (int i = 1; i < 20; i ) {
bufferArea.push(new Product(i));
System.out.println("生产了第" i "