Clojure STM

Although STM has been around for a while, Clojure brought it to the limelight with its revolutionary separation of identity and state, as well as its efficient persistent data structures. Since state is entirely immutable in Clojure, it makes it very easy to use STM—we don’t have to worry about ensuring immutability, because that’s already Clojure’s modus operandi. Clojure also disallows changes to mutable identity from outside of transactions, which makes it very safe. We can enjoy explicit lock-free programming with good concurrent performance and thread safety in applications with an access pattern appropriate for STM. Refer to the examples earlier in Chapter 6, Introduction to Software Transactional Memory, and refer to the ...

Get Programming Concurrency on the JVM 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.