Chapter 9Concurrent Programming in Clojure
by Michael Bevilacqua-Linn
In the previous chapter, we learned about Clojure’s take on value, state, and identity. In this chapter, we’ll take things a bit further and see how Clojure’s philosophy makes it ideal for concurrent programming. As we do so, we’ll take a closer look at Clojure’s managed references—atoms, agents, and refs—as well as the software transactional memory system they work with.
A concurrent program is one where multiple processes, or threads, may be run in parallel. The main difficulty with concurrent programming is coordinating access to shared resources. As we’ll see, this can have strange effects even in seemingly simple situations.
Let’s start off with a look at a simple ...
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