Watch the Video
Or watch it directly on YouTube: Click here
Video Description
Your code runs on a single thread by default. That's about to change. Multithreading unlocks performance but introduces bugs you've never seen before.
What you'll learn:
- What a thread actually is (and isn't)
- Why your CPU has multiple cores
- Creating threads with new Thread()
- Race conditions - the bug that works sometimes
- Why shared data + multiple threads = disaster
- The lock keyword and thread synchronization
- Interlocked operations for atomic updates
- Deadlocks - when threads wait forever
- Why raw threads are the old way
Key insights:
- Threads share memory - that's the problem
- Race conditions pass tests, fail production
- lock serializes access (one thread at a time)
- Interlocked is faster than lock for simple ops
- Always lock the same object for shared data
- Deadlocks happen when lock order differs
- Modern C# uses Tasks, not raw threads
We'll build:
- Multi-threaded counter (and watch it break)
- Race condition demonstration
- Thread-safe counter with lock
- Deadlock scenario (and how to avoid it)
Next Video: Thread-Safe Collections
Finally understand why multithreading is hard? Smash that like button! Subscribe and enable notifications - next up we tackle thread-safe collections!
Chapters
- 0:00 Introduction to Multithreading
- 1:19 Your Code Is Never Really Alone
- 1:45 Inspecting Threads
- 2:32 Creating a Thread (The Old Way)
- 3:22 What Could Possibly Go Wrong?
- 3:50 Race Condition - The Bug That Hides
- 4:36 How Lost Updates Happen
- 5:19 The Solution: Lock Statement
- 5:42 Interlocked - Lock-Free Speed
- 6:35 What's Actually Thread-Safe?
- 7:26 Deadlock - When Locks Lock Up
- 8:19 Threading Don'ts
- 9:27 Threading Is Genuinely Hard
- 9:54 Thread-Safe Collections Preview
- 10:37 Q: When Do I Really Need To Worry About Threading?
- 11:32 Key Takeaways
- 12:35 Practice Challenge
Video Info
- Duration: 14:03
- Published: December 12, 2025