Skip to content

Two threads, one counter

Two threads each run counter = counter + 1 a million times. The final value is 1,374,882 rather than 2,000,000, and it differs every run.

What is happening?