Java Concurrency In Practice Book Review
My reference book on Java concurrency is Doug Lea's Concurrent Programming in Java: Design Principles and Patterns. He is one of the authors of this new book, Java Concurrency In Practice. There is also Joshua Bloch, author of Effective Java, that many people love (but I am less a fan of it, even if I would recommend it to Java newbies), and author of Java Puzzlers, that I found more fun.With such authors, I had relatively high expectations. I was surprised that there is not much material in common between Doug Lea's book and this one, which is a good thing. It's a different presentation, that focuses on different problems.
There is some very interesting material, I especially enjoyed chapter 16 on the Java Memory Model. There are not many books with information on it. I did not know that initializing a final member in the constructor was providing thread safety for the accessor method of the corresponding field if there is no other modifying method, no synchronization needed. And not having the member declared as final was breaking the safety.
I also had not heard of Amdahl's law before. It seems quite intuitive, but then the example in the book about processing parallel tasks using a synchronized LinkedList (improvement up to 3 threads, no more later due to time spent on synchronization) shows that the reality is not that intuitive.
I enjoyed how the book is written, and how information is presented. There is for example their concept of publication and escape (in chapter 3) which tells you important things, like not starting a Thread in a constructor (and if you still want to do it they present a nice way to do it).
I think this book is a simpler read that Doug Lea original book, and probably a better introduction (that still goes very deep) to Java concurrency programming.