O'Reilly logo

Pattern-Oriented Software Architecture: A Pattern Language for Distributed Computing, 4th Volume by Douglas C. Schmidt, Kevlin Henney, Frank Buschmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Synchronization

Synchronization

Kevlin and Frank at JAOO 2006, synchronizing their watches © Mai Skou Nielsen

Concurrency mechanisms for dividing up and executing tasks across different threads present only one part of the concurrency story. Where objects are shared between threads, there is the question of thread-safe use of their methods. This chapter presents nine patterns that address synchronization or reduction of state change to minimize the need for synchronization.

In Chapter 15, Concurrency we discussed how the structure, efficiency and responsiveness of software for distributed systems can benefit from concurrency. We also showed that well-structured, efficient, and responsive concurrent software is surprisingly hard to design: 'Multithreading is one thing after, before, or simultaneously with another' [MeAl04a]. To address these challenges, we therefore included patterns for effective concurrent design in our language. But not only is designing concurrent systems challenging, programming them is too—when present, concurrency is a concern that runs through all levels and across all aspects of an architecture.

One reason why concurrent programming is harder than sequential programming is the need to synchronize access to shared resources. Threads that run concurrently may share access to the same objects. Without appropriate safeguards, therefore, methods that change the internal ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required