關於哲學家就餐問題

2021-06-11 02:32:54 字數 729 閱讀 4555

自己寫的哲學家演算法,大家看看這段**是不是哲學家吃飯問題啊~自己感覺有點不對

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading;

namespace eatingproblem

正在吃東西", thread.currentthread.name);

thread.sleep(2000);

chop[int.parse(thread.currentthread.name)].releasemutex();

chop[(int.parse(thread.currentthread.name) + 1) % 5].releasemutex();

console.writeline("哲學家 正在思考問題", thread.currentthread.name);

thread.sleep(2000);

// monitor.exit(this);}}

static void main(string args)

for (int j = 0; j < 5; j++)

ph p = new ph();

for (int i = 0; i < 100; i++)

console.readkey();}}

}

哲學家就餐問題

本文是哲學家就餐問題在 linux 上的程式實現,與windows 平台的實現類似,程式上稍有不同。philosopherdining.cpp include include include include include include rasutil.h using namespace std ...

哲學家就餐問題

pragma once include include include include include include include include include include include include include stdafx.h handle chopstick 5 room l...

哲學家就餐問題

假設有五位哲學家圍坐在一張圓形餐桌旁,做以下兩件事情之一 吃飯,或者思考。吃東西的時候,他們就停止思考,思考的時候也停止吃東西。餐桌中間有一大碗義大利面,每兩個哲學家之間有乙隻餐叉。因為用乙隻餐叉很難吃到義大利面,所以假設哲學家必須用兩隻餐叉吃東西。他們只能使用自己左右手邊的那兩隻餐叉。哲學家就餐問...