Chapter 2. Exclusion

In a safe system, every object protects itself from integrity violations. This sometimes requires the cooperation of other objects and their methods.

Exclusion techniques preserve object invariants and avoid effects that would result from acting upon even momentarily inconsistent state representations. Programming techniques and design patterns achieve exclusion by preventing multiple threads from concurrently modifying or acting upon object representations. All approaches rely on one or more of three basic strategies:

Eliminating the need for some or all exclusion control by ensuring that methods never modify an object's representation, so that the object cannot enter inconsistent states.

Dynamically ensuring that only one thread ...

Get Concurrent Programming in Java™: Design Principles and Patterns, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.