import java.util.ArrayList;
//测试类
public class MainMethed {
public static void main(String[] args) {
ProductPool pool = new ProductPool(8,new ArrayList<Product>());
Thread thread1 = new Thread(new Produser(pool),"生产者");
Thread thread2 = new Thread(new Consumer(pool),"消费者");
thread1.start();
thread2.start();
}
}
public class Product {
//产品
String name;
public Product(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
import java.util.List;
//放产品的缓冲池
public class ProductPool {
Integer maxNum;
List<Product> list = null;
public ProductPool(Integer maxNum, List<Product> list) {
this.maxNum = maxNum;
一、wait(),notify()实现生产者消费者import java.util.ArrayList;//测试类public class MainMethed { public static void main(String[] args) { ProductPool pool = new ProductPool(8,new ArrayList<Product...