lock ordering
Always taking several locks in the same agreed order, so two threads can't each hold what the other needs.
If every thread acquires locks in one global order, no cycle of waits can form, which rules out deadlock between those locks.
Loading interactive…
Examples
If both threads lock
northbeforesouth, whichever getsnorthfirst also getssouthand the other waits; locking them in opposite orders can deadlock.
See also