Concurrency Anti-pattern Catalog for Java

The deadlock anti-pattern

Problem: ...a situation where two or more processes are unable to proceed because each is waiting for one of the others to do something in a deadlock cycle ... For example, this occurs when a thread holds a lock that another thread desires and vice-versa" [LSW07].

Java example of the problem: ...

Context: Trying to protect access to operations involving shared data.

Solution: Remove unnecessary synchronization if possible. Remove unnecessary nested synchronization if possible. Ensure nested synchronization always occurs in the same order.

Java example of the solution: ...


[LSW07] B. Long, P. Strooper, and L. Wildman, A method for verifying concurrent Java components based on an analysis of concurrency failures," Concurrency and Computation: Practice and Experience, vol. 19, no. 3, pp. 281294, Mar. 2007.