Java Concurrency in Practice - Brian Goetz et al

In my move away from pure functional libraries written in C++ and Haskell to complex distributed systems written in Java, I thought I better get up to date on all that stuff, and this book was highly recommended to me. Basically, relatively recently (like less than 10 years ago), Java got some decent concurrency gizmos, and this book discusses them.

One thing I've learnt is that concurrency is hard. The standard line is that concurrency is hard, but unlike other people I'm clever enough to do it. In my case, this is actually true!

Ahem. I've interviewed plenty of people who have claimed skills in concurrent programming, and most people can't spot a race condition if it'd crash their program. I am, in my experience, reasonably good at spotting nasty things that could happen. However, I'm not cocky enough to feel comfortable writing lots of low-level thread-munging. If I don't screw it up (silly mistakes are still easy to make), it'll still be a maintenance nightmare in the future.

So, this book is wonderfully refreshing. Rather than building from tiny little synchronisation primitives, it discusses high-level concurrency approaches (such as the Java executor framework), and only eventually winds its way down to the nitty-gritty, with plenty of 'don't do this unless you have to - profile first!' advice. Fundamentally, it's taking the right approach to concurrency in most systems. There's enough fundamental complexity in a big system without throwing in the accidental complexity of spurious low-level concurrency primitives.

While the book talks about the Java libraries, it's actually a pretty good introduction to the kind of design approach that should be taken in whatever language when building a concurrent system. Just as you're better off learning object-oriented design through Java rather than C++ (where the fundamental concepts can be lost in a haze of micro-optimisations and C++-specific features), I think this book would give a much better introduction to the subject than, say, reading up on pthreads.

In short, recommended, and not just for Java programmers.

Posted 2012-10-16.