/**
* 一个场景,共同的资源
* 生产者与消费者模式 信号灯法
* 解决多线程防止死锁的方法
*/
public class ProducerAndConsumerModels {
public static void main(String[]args){
//共同的资源
Movie movie = new Movie();
//多线程
Player player = new Player(movie);
Watcher watcher = new Watcher(movie);
new Thread(player).start();
new Thread(watcher).start();
}
}
/**
* 一个场景,共同的资源
* 生产者与消费者模式 信号灯法
* 解决多线