20. Thread Synchronization

In Chapter 19, we discussed the details of multithreaded programming using the Task Parallel Library (TPL) and Parallel LINQ (PLINQ). One topic we specifically avoided, however, was thread synchronization, which prevents race conditions while avoiding deadlocks. Thread synchronization is the topic of this chapter.

A figure shows the "Thread Synchronization" mind-map.

We begin with a multithreaded example with no thread synchronization around shared data—resulting in a race condition ...

Get Essential C# 7.0, Sixth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.