Atom
An atom is a Clojure reference type that supports synchronous, independent, coordinated updates to shared state without explicit locks.
Data-Oriented Programming: Reduce software complexity
An atom is a concurrency-control mechanism that provides coordinated updates to shared state without requiring explicit locks.
- How it is used
- Manages shared counters, caches, and complete system state in multithreaded environments without explicit locks.
- How deep it goes
- Explains get, set, swap, immutable reads, and compare-and-set retries, while deferring detailed starvation analysis.
- Examples
- Uses a database-access counter, an immutable string-map cache, and reconciled system state as progressive examples.
- What you can do after
- Apply it via get, set, and swap to build thread-safe state updates without lock-related deadlocks.
Read how Data-Oriented Programming: Reduce software complexity explains atom →
Clojure: The Essential Reference
clojure.lang.Atom is the Clojure runtime class that wraps a Java AtomicReference to implement atom state management.
- How it is used
- Coordinates synchronous, uncoordinated access to a single shared state reference without explicit locking.
- How deep it goes
- Defines retrying updates, reset semantics, CAS behavior, dereferencing, and the AtomicReference wrapper through executable examples.
- Examples
- Uses counters, nested maps, configuration state, bounded CAS retries, and memoization caches.
- What you can do after
- Apply atom, swap!, reset!, compare-and-set!, and dereferencing to manage shared state.
Related concepts
- concurrency primitivekind of · A concurrency primitive is a fundamental mechanism, construct, or protocol for coordinating concurrent execution and controlling access to shared state or resources.
- memoizationused by · Memoization is an optimization technique that stores computation results with their inputs so equivalent later evaluations can reuse them without recomputation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

