资源简介
进程同步模拟设计--生产者和消费者问题 进程调度同步异步
代码片段和文件信息
class Producer implements Runnable
{
private Semaphore mutexfullempty;
private Buffer buf;
String name;
public Producer(String nameSemaphore mutexSemaphore fullSemaphore emptyBuffer buf)
{
this.name = name;
this.mutex = mutex;
this.full = full;
this.empty = empty;
this.buf = buf;
}
public void run()
{
while(true)
{
empty.p();
mutex.p();
System.out.println(name+“ inserts a new product into “+buf.nextEmptyIndex);
buf.nextEmptyIndex = (buf.nextEmptyIndex+1)%buf.size;
mutex.v();
full.v();
try
{
Thread.sleep(1000); //必须捕获异常
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
class Customer implements Runnable
{
private Semaphore mutexfullempty;
private Buffer buf;
String name;
public Customer(String nameSemaphore mutexSemaphore fullSemaphore emptyBuffer buf){
this.mutex = mutex;
this.full = full;
this.empty = empty;
this.buf = buf;
this.name = name;
}
public void run()
{
while(true)
{
full.p();
mutex.p();
S
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2868 2010-01-22 21:38 Test.java
----------- --------- ---------- ----- ----
2868 1
- 上一篇:PReS指令集详细说明教程
- 下一篇:飞思卡尔K60 ADC
相关资源
- wxu998.rar
- PowerDesigner16.5汉化文件.rar
- jsgis.zip
- PinyinIME(关键代码写了注释).zip
- 锁相环设计、仿真与应用第5版中.pd
- novelOnLine.zip
- SingleSensorImagingMethodsandApplicationsforDi
- ControlSystemsEngineering7th(NormanS.Nise)
- ModernControlSystems13th(RichardC.Dorf).ra
- VectorMagic_1.15pojie.rar
- complexityoflattice__problems.pdf
- xnby_883749.zip
- TOGAF培训讲义-周金根.pdf
- OS12.2驱动,手机虚拟定位软件,Loca
- 大话系列-大话数据结构(pdf高清版)
- 梁宁产品经理思维30讲.pdf
- CHI760E辰华电化学工作站软件最新版
- SAPERPHCM葵花宝典系列之配置指南(电
- TangZhuoLin.rar
- Day3_NOI.zip
- 图解HTTP.pdf
- VisionProStandardv7.2(2Day).zip
- ElevatorSimulation.zip
- 14002454IPC-A-610DChinese(L).pdf
- SoftwareEngineering.pdf
- linfanrong_10164999.rar
- The.Art.Of.Unit.Testing.With.Examples.in.C.2nd
- myGame.rar
- 带手机版数据同步财税代理公司注册
- pdf课本及习题答案.rar
评论
共有 条评论