Concurrency was one of the chief design goals of Clojure. Considering the concurrent programming model in Java, it is not only too low level but also so tricky to get right that without strictly following patterns, you are more likely to shoot yourself in the foot. Locks, synchronization, and unguarded mutation—these are recipes for concurrency pitfalls unless exercised with extreme caution. Clojure's design choices deeply influence the way concurrency patterns can be achieved in a safe and functional manner. In this chapter we will discuss:
Low-level concurrency support at the hardware and JVM levels
The concurrency primitives of Clojure—atoms, agents, refs, and vars
The built-in concurrency features in Java that are safe and useful for use with Clojure
Parallelization with Clojure features and reducers