Two threads, one counter
count: 0
π§΅ T1
read
+1
write
π lock
reg: β
π§΅ T2
read
+1
write
π lock
reg: β
π DEADLOCK
π·Hog A
served: 0
π·Hog B
served: 0
πPolite
waited: 0
count++ is three steps, not one
Click βΆ Interleave to run two threads one micro-step at a time.
βΈ
A race passes 99 test runs and fails in production β the bug is the timing, not the code you can see.