previous | start | next

Multiple Locks

If two threads each want to lock the same to mutexes, there is a danger of deadlock.

This can be prevented if the code is written so that all threads try to lock the mutexes in the same order.

Prevention this way is easy (if we remember to do it). Detecting deadlock after the fact or allowing any order of locks and trying to check if each lock will cause deadlock is hard.



previous | start | next