Chapter 18

Atomicity and Locking

During the execution by a thread of a compound operation that consists of multiple steps, other threads can observe and interfere with the state of an application as it exists between these steps. By contrast, an atomic operation consists of a single step, with no possibility of disruption during that step. Locking is a mechanism that can be used to make a compound operation by a thread appear atomic to other threads, thereby preventing them from interfering during its execution in ways that would be detrimental to correctness. Different systems define their own locking mechanisms. In particular, Java defines a basic form of locks that can be used with any JVM language.

18.1 Atomicity

Chapter 17 discussed a ...

Get Functional and Concurrent Programming: Core Concepts and Features now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.