Book Image

Concurrent Patterns and Best Practices

By : Atul S. Khot
Book Image

Concurrent Patterns and Best Practices

By: Atul S. Khot

Overview of this book

Selecting the correct concurrency architecture has a significant impact on the design and performance of your applications. Concurrent design patterns help you understand the different characteristics of parallel architecture to make your code faster and more efficient. This book will help Java developers take a hands-on approach to building scalable and distributed apps by following step-by-step explanations of essential concepts and practical examples. You’ll begin with basic concurrency concepts and delve into the patterns used for explicit locking, lock-free programming, futures, and actors. You’ll explore coding with multithreading design patterns, including master, slave, leader, follower, and map-reduce, and then move on to solve problems using synchronizer patterns. You'll even discover the rationale for these patterns in distributed and parallel applications, and understand how future composition, immutability, and the monadic flow help you create more robust code. By the end of the book, you’ll be able to use concurrent design patterns to build high performance applications confidently.
Table of Contents (14 chapters)


We saw many primitive synchronizations in this chapter. We started with the bounded buffer and saw how it prevents an overloaded application from running out of memory. The client contract is realized using reentrant locks. 

Next, we discussed the readers-writer locking; this is the pattern that increases read concurrency. We also looked at counting semaphores, countdown latches, barriers, and future tasks. We will be looking at the applications of these primitives in the upcoming chapters.      

Resource pooling is realized using counting semaphores. For example, database connection pooling and thread pooling allow an application to pool and use resources efficiently.

Thread pools offer the same benefit for thread management. java.util.concurrent provides a flexible thread pool implementation as part of the executor framework. 

We will take a detailed look at thread pooling in the next chapter.