Concurrent Programming in Java: Design Principles and Pattern, 2nd Edition
Review by Sven Woltmann
Concurrency has always been a first-class citizen in Java. Threads, monitors (keyword synchronized), and guarded blocks (wait/notify) have been part of the language since Java 1.0.
“Concurrent Programming in Java” is from 1999 and thus on the level of Java 1.2. Nevertheless, the described challenges of concurrent programming (security, liveness, performance) are still relevant today. So are the presented principles and design patterns, like synchronization and confinement, monitors, guarded waits and notifications, latches, worker threads, futures, fork/join, and many more.
Abstracting from this, the author introduces more complex, reusable utility classes for initiating and coordinating concurrent activities. Most of these classes are today – in an evolved form – part of the JDK. In the JavaDoc of these classes (e.g., Semaphore, ReentrantLock, Executor, or CountDownLatch – and in newer ones like CompletableFuture or StampedLock), you will find the signature of Doug Lea, the author of this book.
The book is not a light read. The writing style is academic and highly challenging. I had to read many paragraphs more than once and keep cross-referencing to other parts of the book to understand. With the examples, it is sometimes advisable to read the theory first, then the source code, and then the theory again. Every few pages, you have to take a break.
It took me several weeks to work through the entire work. But it is definitely worth the effort!
Once you have internalized the basics of this book, you will be able to write performant, thread-safe code and quickly recognize non-thread-safe code as well as the causes of race conditions. That will make you one of the most sought-after Java programmers.
🎧 Suitable as an audiobook? No, due to numerous diagrams and code examples.
Other Recommendations From This Book’s Genres
Java Concurrency in Practice
Effective Java (Third Edition)
Java Generics and Collections
Core Java: Fundamentals (Volume 1)
Core Java: Advanced Features (Volume 2)
Java Puzzlers: Traps, Pitfalls, and Corner Cases
Mastering Lambdas: Java Programming in a Multicore World
The Pragmatic Programmer: From Journeyman to Master
Get Your Hands Dirty on Clean Architecture: A hands-on guide to creating clean web applications with code examples in Java
Clean Code: A Handbook of Agile Software Craftsmanship
Refactoring: Improving the Design of Existing Code
Clean Craftsmanship: Disciplines, Standards, and Ethics
The Programmer’s Brain: What Every Programmer Needs to Know About Cognition
Working Effectively with Legacy Code
Design Patterns: Elements of Reusable Object-Oriented Software