Short review of "Java Concurrency in Practice" and others...
The first mentioned book is completely outdated. The author explain step-by-step how to perform certain refactorings manually, but nowadays any mature IDE will do those refactorings automatically in not more than two mouse clicks. Besides, most of explained approaches are simply trivial and obvious. If I have the same statement at the beginning of if block and else block, I don’t need a book to figure out, that those duplicated statements can be moved before if condition. Also reading how to extract interface from existing class or advices like "rename your method so that its name better explains what it does" is wasting time of any reasonable developer. Fowler does a great job of emphasizing the role of refactoring and unit testing, but short article with a table of major Java IDEs refactoring shortcuts is enough for today.
The latter book is a set of short Java code snippets, mostly followed by well known "what will the program print?" question. But the real question is "why even bother?" Do we really need to know that backslash still escapes characters in comments? Is knowledge of every detail of Java Language Specification is really necessary to call ourselves so-called "professional developers"? Although I have found many surprising and interesting examples in this book, it reminded me SCJP exam too much. And it is not a compliment.
Now it’s time for the winner, "Java Concurrency in Practice". Great thing about this reading is that it covers the subject of concurrency from all points of view. Starting from Amdahl's law, which should be known by every software engineer taking advantage of multitasking, through the details of JVM and CPU architecture to explaining new concurrency API. All of that in less than 400 pages.
I can’t remember when was the last time I heard how many CPU cycles does particular Java operation take – thanks to Brian Goetz I am not feeling disgusted by such a nasty technical details. Also the author introduces many charts and does some research to discover which implementation is actually fastest for some example problem. Besides, new Java concurrency API (thread pools, atomic primitives, collections) is introduced and discussed, also from implementation side. For example, look at the source code of Sun’s implementation of AtomicInteger, which is thread safe. I felt pretty amazed when I discovered that synchronized keyword or any other synchronization mechanism has not been used in this class. How is it possible while still preserving thread-safety? This book answers many more questions.
"Java Concurrency in Practice" will not introduce you another framework, simple servlet example is probably all what you get. But I am sure that the quality and performance of my code has improved after reading this great book. Learn how to use threads effectively – and how to avoid them.
For something more up-to-date, I am finishing "Programming Groovy: Dynamic Productivity for the Java Developer", so expect a few blog entries inspired by this book. But I am in a hurry, because I can’t wait to start "Modular Java: Creating Flexible Applications with OSGi and Spring". So please expect OSGi soon. Tags: concurrency, refactoring, review