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.
What to know first
- compare-and-swapCompare-and-swap is an atomic operation that replaces a value with a desired value only if the current value matches an expected value.
- critical sectionA critical section is a region of program execution that accesses shared state or resources and requires coordination to prevent conflicting concurrent operations.
Related concepts
- concurrency primitivekind of · A concurrency primitive is a fundamental language or runtime mechanism for coordinating concurrent execution or controlling access to shared state or resources.
- deadlockaddresses · A deadlock is a state in which concurrent activities cannot progress because each is waiting for a resource, event, or action that depends on another blocked activity.
- lock-freekind of · Lock-free is a concurrency progress guarantee under which at least one operation completes within a finite number of steps despite contention, without relying on mutual-exclusion locks.
Questions about atom
What is atom?
An atom is a Clojure reference type that supports synchronous, independent, coordinated updates to shared state without explicit locks.
Which Manning books explain atom?
Data-Oriented Programming: Reduce software complexity and Clojure: The Essential Reference.
What should I know before learning atom?
Manning books that teach atom usually introduce compare-and-swap and critical section first.
What is the difference between atom and delay??
An atom is a Clojure reference type that supports synchronous, independent, coordinated updates to shared state without explicit locks. delay? is a Clojure function that tests whether a value is a delay object.
What is atom a kind of?
Atom is a kind of concurrency primitive. A concurrency primitive is a fundamental language or runtime mechanism for coordinating concurrent execution or controlling access to shared state or resources.
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.

