用点菜和吃菜来做模拟(生产者和消费者的多线程关系)
?
这里的厨房代表生产者
?
public class CustomThreadExample {public static void main(String[] args) {Food food = new Food();Maker maker = new Maker(food);Eater eater = new Eater(food);new Thread(maker).start();new Thread(eater).start();}}
?