Chapter 5: Thread synchronization and classic problems
In this chapter
- Why synchronization is needed: the risk of shared data
- Classic problems
- Race condition
- Deadlock
- Common deadlock-prevention strategies
- Synchronization mechanisms
Interlocked: atomic operations on a single field- The
lockkeyword: the simplest lock - A more modern lock:
System.Threading.Lock(.NET 9+) - The boundary between
lockandasync SemaphoreSlim: limiting concurrencyMutex: cross-process synchronization
- Summary
This chapter is not available in the free preview. Purchase the book to read the complete edition now.