O'Reilly logo

Essential C# 4.0 by Mark Michaelis

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

19. Synchronization and More Multithreading Patterns

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

image

We begin with a multithreaded example with no thread synchronization around shared data—resulting in a race condition in which data integrity is lost. This serves as the introduction for why we need thread synchronization followed by myriad mechanisms and best practices for ...

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