using system;
using system.collections.generic;
using system.text;
using system.threading;
namespace monitertest
console.writeline("worker1:" + worker1count.tostring());
console.writeline("worker2:" + worker2count.tostring());
console.writeline("worker3:" + worker3count.tostring());
console.read();
}static void worker(object o)
while (!isover)
else
}catch (exception e1)
finally
if (getgood)
console.writeline(name + " put good " + i.tostring() + " on ship!");
if (i == maxgoodcount)
}catch (exception e2)
finally
}thread.sleep(timespan);}}
static void producer()
console.write("/n");
thread.sleep(3000);
}catch (exception e)
finally}}
}}
c 中Monitor的使用
首先lock和minitor有什麼區別呢?其實lock在il 中會被翻譯成monitor。也就是monitor.enter obj 和monitor.exit obj lock obj 等價為 try catch finally 所以lock能做的,monitor肯定能做,monitor能做的,lo...
c 中Monitor的使用
首先lock和minitor有什麼區別呢?其實lock在il 中會被翻譯成monitor。也就是monitor.enter obj 和monitor.exit obj lock obj 等價為 trycatch finally 所以lock能做的,monitor肯定能做,monitor能做的,loc...
c 中Monitor的使用
首先lock和minitor有什麼區別呢?其實lock在il 中會被翻譯成monitor。也就是monitor.enter obj 和monitor.exit obj lock obj 等價為 trycatch finally 所以lock能做的,monitor肯定能做,monitor能做的,loc...