Chapter 5Use Your Cores
Servers, laptops, and even phones these days are built on multicore chips with multiple independent threads of control available for programs to use. We need to design our programs to take full advantage of these chips. Clojure was born in and designed for this multicore world.
Most of the problems with concurrency in languages like Java are problems of managing shared mutable state. As we’ve seen, Clojure relies primarily on immutable data (which can be safely used across threads). We’ve also seen how explicit state can be created using the stateful containers (atoms, refs, agents, and vars). All of these containers use a common update model whereby state is always transformed from one immutable value to another with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access