Threads, shared state, and atomicity
What total should two successful atomic increments leave?
Examples
Worked example
Input
Two threads each increment a shared counter starting at 0.
Expected output
2
Hints and solution
Hint 1
Write down the starting state and walk through one example by hand.
Reveal worked answer
One increment changes 0 to 1 and the other changes 1 to 2. Each sees the latest atomic value.