Java Concurrency in Practice – Book Review

DZone 's Guide to

Java Concurrency in Practice – Book Review

· Java Zone ·
Free Resource

I used my holidays to concentrate on the reading of my latest book : Java Concurrency in Practice by Brian Goetz (with Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes and Doug Lea). This book is, in my point of view, the reference for the development of concurrency programs in Java.

Reading this book, you will learn that concurrency is everywhere when programming in Java; all the examples are in Java, but the theory  is valid for almost all programming languages. You will also learn why the GUI Frameworks are single-threaded. You will also understand that a lot of Java programs aren’t correct because of the lack of thread safety.

The first chapter, the introduction, explains what  threads are and why we use parallel processing. It also contains the first interleaving example (really simple) and how to solve it. In the third chapter, the author explains what Thread Safety is and how to achieve it using locks (intrinsic locks with synchronized). In the next chapter, you learn how to share objects between several threads. This include the notions of visibility, immutability, thread confinement and safe publication. With the fourth chapter, you learn how to design a thread safe class, delegate the thread safety to another class and learn why it’s really important to document the synchronization policies. In the last chapter of this first part, we see how to build blocks of statements. We use concurrent collections, blocking queues, synchronizers, blocking and interruptible methods.

The second part is about structuring concurrent applications. It contains information about the executor framework, finding parallelism, the cancellation and the shutdown of tasks, thread pools and GUI applications.

The third part is about liveness hazards, performance and scalability and also about testing concurrent programs.

The last part describes advanced topics. It contains explicit locks using ReentrantLock. It explains also how to build custom synchronizers. A chapter is included about building concurrent programs using non-blocking algorithms. These algorithms are better performing but a lot more difficult to build. And the last chapter is about the Java Memory Model. This chapter is very technical but really interesting if you want to deeply understand the Java language.

To conclude, this book is a reference for every person who want to write concurrent applications.

From http://www.baptiste-wicht.com/2010/08/java-concurrency-in-practice-book-review/


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}