Concurrency Anti-pattern Catalog for Java

A "blocking" critical section anti-pattern

Problem: “A thread is assumed to eventually return control but it never does" [FNU03].

Java example of the problem: ...

Context: Using locks to try and protect access to operations involving shared data.

Solution: Ensure that every lock() acquisition has a corresponding unlock(). If it is possible to throw an exception inside a critical region the unlock() must be placed in a finally block. The finally block will be executed regardless if the exception is thrown.

Java example of the solution: ...


[FNU03] E. Farchi, Y. Nir, and S. Ur, “Concurrent bug patterns and how to test them," in Proc. of the 1st International Workshop on Parallel and Distributed Systems: Testing and Debugging (PADTAD 2003), Apr. 2003.