Java的线程池
-
并发协作模型:生产者/消费者模式-->信号灯法(判断标志位)
package com.kuang.hyperprocess;
//测试生产者消费者问题2:信号灯法,通过标志位解决。
public class TestPc2{
public static void main(String[] args){
TV tv = new TV();
new Player(tv).start();
new Watcher(tv).start();
}
}
//生产者-->演员
class Player extends Thread{
private TV tv;
public Player(TV tv){
this.tv = tv;
}