Review : Java 7 Concurrency Cookbook

The Java 7 Concurrency Cookbook, containing over 60 examples show you how to do multithreaded programming in Java. It shows varies threading topics from beginner level to advanced level, including thread management like create, interrupt and monitor thread, using Java 5 Executor frameworks to run or schedule threads, and the latest Java 7 fork/Join Frameworks to distribute threads.

My favorite is chapter 3, showing 5 examples of common concurrent mechanisms or patterns – “Semaphores“, “CountDownLatch“, “CyclicBarrier“, “Phaser” and “Exchanger“, and how these mechanisms solve existing threading problem. In additional, at the end of the chapter, it surprises me by showing how to test Java concurrent code in both Eclipse and NetBean.

See following section to know what will you learn from this book.

Chapter 1: Thread Management

Hello world chapter with many useful examples to show you the basic of Thread management.

Skills are learned:

  1. How to create, interrupt, sleep and resume a thread.
  2. How to program a Daemon thread.
  3. How to process thread exceptions.
  4. How to grouping threads into a group.

Chapter 2: Basic Thread Synchronization

Thread synchronization to control how the multiple threads read and write the same data, files or database (shared resources),

Skills are learned:

  1. How to use the synchronized keyword, to synchronize a method.
  2. How to use the Lock interface and its implementations, to synchronize a block of code.
  3. How to do single / multiple conditions in synchronized code, using wait(), notify(), and notifyAll().

Chapter 3: Thread Synchronization Utilities

Examples to show you the five common concurrent mechanisms or patterns to synchronize multiple threads, and what problem it is solving.

Skills are learned:

  1. Semaphores – A counter that controls the access to one or more shared resources.
  2. CountDownLatch – Allows a thread to wait for the finalization of multiple operations.
  3. CyclicBarrier – Allows the synchronization of multiple threads in a common point.
  4. Phaser – Controls the execution of concurrent tasks divided in phases.
  5. Exchanger – Provides a point of data interchange between two threads.

Chapter 4: Thread Executors

How to work with the Java 5, Executor frameworks – Executor, ThreadPoolExecutor and etc. It like a scheduler to run a single or multiple threads at the specified time or interval.

Skills are learned:

  1. How to create a thread executor
  2. How to run a task after a delay.
  3. How to run a task periodically.
  4. How to controlling task finishing or canceling.

Chapter 5: Fork/Join Framework

New Java 7 Fork/Join Framework.

Skills are learned:

  1. What’s Java 7 Fork/Join Framework, and a simple hello world example.
  2. How to joining the results from the divided tasks.
  3. How to canceling a task.

Chapter 6: Concurrent Collections

Introduce Java collections that used in the concurrent programming.

Skills are learned:

  1. What’s blocking and non-blocking collections.
  2. Examples to use blocking and non-blocking thread-safe list.
  3. ConcurrentNavigableMap example.
  4. How to generate concurrent random numbers with ThreadLocalRandom.
  5. How to use atomic variables – e.g AtomicLong, and atomic arrays – e.g AtomicIntegerArray.

Chapter 7: Customizing Concurrency Classes

This chapter shows you how to customize existing concurrency classes to suit your needs. Often times, you don’t need this, but good to know.

Skills are learned:

  1. Implementing a priority-based Executor class
  2. How to use ThreadFactory.
  3. Customizing tasks running in a scheduled thread pool and in the Fork / Join framework.
  4. How to implement a custom Lock class.
  5. How to implement your own atomic object.

Chapter 8: Testing Concurrent Applications

This chapter shows you how to test in your concurrent program.

Skills are learned:

  1. How to monitor Lock, Phaser, Executor framework and Fork/Join pool.
  2. How to configure Eclipse and NetBeans for debugging concurrency code.
  3. How to analyze concurrent code with FindBugs


This book contains a lot of easy to follow examples, and well-explained at the end of each example, except the chapter 6 and chapter 7, which required some years of threading background to understand. For beginners who want to learn threading in Java, this “Java 7 Concurrency Cookbook” is the best book to study. For experienced developers, you also can treat this as a complete reference of “Java Concurrency”.

What if compare with the classic Java Concurrency in Practice? I think both books are targeted for different developer level. IMHO, the classic “Java Concurrency in Practice” is for advanced level, its snippet code is followed by a few pages of explanations is great, but not suitable for anyone. And this Java 7 Concurrency Cookbook is for beginner and immediate level, the example is easy to understand and ready to modify for your project use.

This Java 7 Concurrency Cookbook is able to purchase online via or


  1. Oracle Java concurrency tutorials
  2. Java 7 fork/join frameworks

About the Author

author image
Founder of, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


8 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
6 Comment authors
Shyamsreehareesh48??????????? - Java 7 ???? - ImportNewDeepak Recent comment authors
newest oldest most voted

Thanks for sharing it..

Please share this book with me.



i like open source stuffs only

??????????? - Java 7 ???? - ImportNew

[…] ?????mkyong????ImportNew¬†– ??? […]


Hi, Can you please send that ebook to me.
Here is my email id.

Hmm is anyone else encountering problems with the images on this blog loading?

I’m trying to figure out if its a problem on my end or if it’s the
blog. Any suggestions would be greatly appreciated.


I like to know the Thread concepts because am the beginners and interested to know it.Am Eagerly looking for this book how it is explained about this concept and having hope this book should make understandable and easier to learn too.

Win a free copy of Java 7 Concurrency Cookbook

[…] week, I wrote a full review of the book – Java 7 Concurrency Cookbook, and the article is promoted to a big link on […]

Siddhanta Pattnaik
Siddhanta Pattnaik

Thanks,for sharing this book .