In Part 1, we saw a Java program that compiled perfectly but behaved incorrectly at runtime —
a worker thread that never stopped, even after a shared flag was updated.
In Part 2, we go deep into why that happens.
What you’ll learn in this video:
How Thread Stacks and the Heap actually work in Java.
Why threads can see stale values even when code looks correct.
The two most common concurrency bugs:
Race conditions
Visibility problems
How synchronized guarantees atomicity and visibility?
When and why to use the volatile keyword?
What instruction reordering is — and why it breaks multi-threaded code?
The happens-before relationship, explained with real examples.
How CPU cache coherency works under the hood?
What false sharing is and why it hurts performance in high-throughput systems?
This video is ideal for:
Backend engineers
Interview preparation
▶️ Watch Part 1 first to see the bug that started this entire discussion.
#Java #Concurrency #JavaMemoryModel #Multithreading #Volatile #Synchronized #HappensBefore
#CPUCache #CacheCoherency #FalseSharing #BackendEngineering #SoftwareArchitecture #PerformanceEngineering
Download
0 formats
No download links available.
Java Memory Model Explained Part 2 | Volatile, Synchronize, Happens-Before & CPU Cache Effects | NatokHD