现在的位置: 首页 > 综合 > 正文

什么是死锁?如何防止死锁?

2013年08月01日 ⁄ 综合 ⁄ 共 426字 ⁄ 字号 评论关闭

当两个或多个竞争的动作在等待其他动作结束,但这种情况不会发生,则称之为死锁。

一旦死锁发生,便会存在以下四个必要条件:

1. 互斥

2. 保持与等待

3. 不可抢占

4. 循环等待

只要可以去除上述条件中的任意一个条件,便可以消除死锁。

 

Dead-Lock

Dead-lock is situation when two or more competing actions are each waiting for the other to finish, but thus never does.

There are four necessary conditions when a dead-lock occurs: mutual exclusion, hold and wait, no preemption, circular wait. If we can remote one of the conditions, the dead-lock will be avoided. We can use a monitor thread to detect the dead-lock.

 

抱歉!评论已关闭.