Locks are incorporated in Java; every Object has a lock that a thread may acquire when it enters a synchronized block. We discussed that already. In some programming code, there are situations when this kind of structure is not optimal.
In some situations, the structure of locks may be lined up to avoid deadlock. It may be needed to acquire lock A before B, and to acquire B before C. However, A should be released as soon as possible, to allow access to a resource protected by lock D, also needing lock A before it. In complex and highly parallel structures, the locks are frequently structured as trees. A thread should climb down along the tree to a leaf representing the resource to acquire the lock. In the act of climbing, the thread gets hold of a lock on a node, then a lock on a node below it, and then releases the lock above, just like a real climber descending (or climbing...