Chapter 2. Thread Synchronization
In this chapter, we will describe some of the common techniques of working with shared resources from multiple threads. You will learn the following recipes:
- Performing basic atomic operations
- Using the
Mutex
construct - Using the
SemaphoreSlim
construct - Using the
AutoResetEvent
construct - Using the
ManualResetEventSlim
construct - Using the
CountDownEvent
construct - Using the
Barrier
construct - Using the
ReaderWriterLockSlim
construct - Using the
SpinWait
construct
Introduction
As we saw in Chapter 1, Threading Basics, it is problematic to use a shared object simultaneously from several threads. However, it is very important to synchronize those threads so that they perform operations on that shared object in a proper sequence. ...
Get Multithreading with C# Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.