Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 21s8 days 9 hours 54 minutes 21 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 8d 09h 54m 21s8 days 9 hours 54 minutes 21 seconds.

Sign in to watch this lesson
Threads and Their Lifetimes · 4:28
Two threads share one address space but each has its own program counter, registers and stack, so a global counter really is shared. Following OSTEP's counter example, we run two threads that each add ten million to it on a Mac, read the arm64 code clang -O2 produces, step through the load, add and store interleaving that loses an update, and catch the data race with ThreadSanitizer even when the printed answer looks right.