Atoms

Atoms allow for synchronous (immediate) and independent changes to data. Also, the changes are not coordinated with other threads. Either all of them happen or none of them do.

Start repl to follow along, and type the following code:

lein repl

We can create atom in the following way:

(def basket-counter (atom 0))

We created atom to hold a number of items in a shopping basket. The initial value is 0.