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)

Summary


In this chapter, we introduced the actor paradigm. We used a real-world analogy, a software company and its employees, to correlate various terms used in the paradigm. There are reasons for using ActorRef as a proxy to refer to an actor. We saw how let it crash and location transparency are realized due to the ActorRef encapsulation, working as a proxy to the actual actor reference.

We covered the aspect of actors for state encapsulation. We also saw what actors are and how they map to threads. Next, we covered some essential and common actors patterns.

The become pattern is used for changing an actor's behavior. We saw how it helps in making the actor state immutable. Next, we saw how the supervision model works, so if an actor crashes, another copy is restarted.

Finally, we covered basic actor communication patterns such as ask, tell, and pipeTo. We also looked at the care needed when we use actors with future tasks.