91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 0.92KB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-03-27
  • 語(yǔ)言: 其他
  • 標(biāo)簽: 其他??

資源簡(jiǎn)介


進(jìn)程同步模擬設(shè)計(jì)--生產(chǎn)者和消費(fèi)者問(wèn)題 進(jìn)程調(diào)度同步異步

資源截圖

代碼片段和文件信息

?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

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????2868??2010-01-22?21:38??Test.java

-----------?---------??----------?-----??----

?????????????????2868????????????????????1


評(píng)論

共有 條評(píng)論