进阶day06-等待唤醒功能实现(生产者与消费者)
This commit is contained in:
15
javaSE-day06/src/com/inmind/wait_notify08/Demo09.java
Normal file
15
javaSE-day06/src/com/inmind/wait_notify08/Demo09.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.inmind.wait_notify08;
|
||||
//测试类:创建包子,包子铺,吃货线程,让子线程运行起来
|
||||
public class Demo09 {
|
||||
public static void main(String[] args) {
|
||||
BaoZi baoZi = new BaoZi();//被包子铺,吃货线程共享,用来进行线程间通信
|
||||
//创建2个线程任务来实现2个线程按照我们所需的顺序来执行(一定是先有包子再吃)
|
||||
BaoZiPu baoZiPu = new BaoZiPu(baoZi);
|
||||
ChiHuo chiHuo = new ChiHuo(baoZi);
|
||||
|
||||
new Thread(baoZiPu).start();
|
||||
new Thread(chiHuo).start();
|
||||
|
||||
System.out.println("程序结束");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user