Advanced Synchronization in Java Threads, Part 2
Subject:   deadlock detection
Date:   2004-11-01 05:39:57
From:   simbo
DeadlockDetectingLock looks good for trying to locate a problem after it has been designed into a system. the article recommends a a "lock hierarchy" to avoid introducing the problem. the lock hierarchy simply dictates the ordering that locks must be acquired in. would it not then be a good idea to design a class that encapsulates the ordered sequence of locks?
such a class might then enforces that locks are acquired in sequence order. that is to say that if a thread holds locks [A, B, G, W] it can grab any of the locks [X, Y, Z] but not any locks lower than W. could the algorithm to enforce such a rule be fast enough to go into production?