producer.java
来自「this is test program which tries to solv」· Java 代码 · 共 45 行
JAVA
45 行
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author bits07a004 */public class Producer extends Thread{ private CubbyHole cub; private int num; public Producer( CubbyHole _cub ) { cub = _cub; } public void run() { try { while(true) { sleep( (int)( Math.random() * 10 ) ); if( cub.isEmpty() ) { num++; cub.takeValue( num ); System.out.println("Producer: " + num ); } if( num > 10 ) break; } }catch( Exception e ) { System.out.println(e); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?