⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 producer.java

📁 this is test program which tries to solve producer consumer problem
💻 JAVA
字号:
/* * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -