Concurrency Anti-pattern Catalog for Java

The interference anti-pattern

Problem: A pattern in which “...two or more concurrent threads access a shared variable and when at least one access is a write, and the threads use no explicit mechanism to prevent the access from being simultaneous." [LSW07]. The interference bug pattern can also be generalized from classic data race interference to include high level data races which deal “...with accesses to sets of fields which are related and should be accessed atomically" [AHB03].

Java example of the problem: ...

Context: Trying to use operations involving shared data without protecting the access to the shared data.

Solution: Use synchronization to protect both write and read access to shared variables.

Java example of the solution: ...

References:

[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. 281–294, Mar. 2007.

[AHB03] C. Artho, K. Havelund, and A. Biere, “High-level data races," in Proc. of the 1st International Workshop on Verification and Validation of Enterprise Information Systems (VVEIS’03), Apr. 2003.