Two threads each run count = count + 1 on a shared variable without synchronisation, and the final value is sometimes wrong. What is this called?
Correct answer C. A race condition
Explanation
count = count + 1 is a load, an add and a store; if the threads interleave between those steps, one update can overwrite the other. When the outcome depends on the precise timing of accesses to shared data, that is a race condition. Deadlock is processes waiting for each other forever, and starvation is one process being postponed indefinitely.
Answer checked How we write and check questions
Discussion