Writing scalable applications that use the capabilities of today's multi-core CPUs while running reliably and with high performance is a challenge. Race conditions, deadlocks, and other liveness errors quickly creep in.
Brian Goetz and a team of experts from Java Specification Request 166 "Concurrency Utilities" describe in "Java Concurrency in Practice" the fundamental concepts of thread safety and the correct implementation of thread-safe applications in Java.
The book is divided into four parts:
All explanations are accompanied by excellent real-world code examples. Most show frequently made but incorrect implementations first, followed by the correct ones.
The authors successfully explain an extremely complex topic in a relatively simple way. Of particular note is the excellent explanation of the Java Memory Model and the "happens-before" relationship.
Nevertheless, the book is not an easy read, and it takes time to understand all the details. I recommend reading the book at least twice.
Even though the book is on the level of Java 6, it is still up-to-date. The basics of thread safety have not changed since, and all features added in later Java versions (like the fork/join framework, CompletableFuture, or parallel streams) are based on them.
🎧 Suitable as an audiobook? No, due to numerous extensive code examples.
P.S.: If you want to go deeper into the advanced topics and read about specific types of memory fences and advanced memory access methods like release/acquire and opaque, I recommend Doug Lea's "Concurrent Programming in Java" as a follow-up reading.
* Disclosure: We love sharing our favorite books with you! As an Amazon Associate, we earn a small commission from purchases you make through our links, which helps us continue creating content you enjoy.