Skip to content

What is a race condition?

Two threads both run counter = counter + 1 on a shared counter that starts at 0.

Afterwards it sometimes reads 1 instead of 2. Why?