Concurrency Anti-pattern Catalog for Java

Two-state access bug anti-pattern

Problem: “Sometimes a sequence of operations needs to be protected but the programmer wrongly assumes that separately protecting each operation is enough" [FNU03].

Java example of the problem: ...

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

Solution: Combine the multiple critical regions into one critical region.

Java example of the solution: ...

References:

[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.