If It Hurts, Stop Doing It

The rules about locking that we discussed in Chapter 2, ​Threads and Locks​, apply only to data that is both shared between threads and might change—in other words shared mutable state. Data that doesn’t change (is immutable) can be accessed by multiple threads without any kind of locking.

This is what makes functional programming so compelling when it comes to concurrency and parallelism—functional programs have no mutable state, so they cannot suffer from any of the problems associated with shared mutable state.

In this chapter we’re going to look at functional programming in Clojure,[9] a dialect of Lisp that runs on the JVM. Clojure is dynamically typed; and if you’re a Ruby or Python programmer, ...

Get Seven Concurrency Models in Seven Weeks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.