In the last chapter, we saw some parallel programming implementations in which resources needed to be protected from concurrent access by multiple threads. Synchronization primitives are tricky to implement. Often, a shared resource is a collection that needs to be read and written by multiple threads. Since a collection can be accessed in a variety of ways (such as by using Enumerate, Read, Write, Sort, or Filter), it becomes tricky to write a custom collection with managed synchronization using primitives. Because of this, there has always been a need for thread-safe collections.
In this chapter, we will learn about various programming constructs available in C# that help in parallel development. The following are the high-level topics that will be covered in this chapter:
- An introduction to concurrent collections
- A multiple producer/consumer scenario...