What is the difference between Race Condition and Data Races? Are they the same?

Technology CommunityCategory: ConcurrencyWhat is the difference between Race Condition and Data Races? Are they the same?
VietMX Staff asked 3 years ago
  • data race occurs when 2 instructions from different threads access the same memory location, at least one of these accesses is a write and there is no synchronization that is mandating any particular order among these accesses.
  • race condition is a semantic error. It is a flaw that occurs in the timing or the ordering of events that leads to erroneous program behavior. Many race conditions can be caused by data races, but this is not necessary.

The Race Condition and Data Races are not the same thing. They are not a subset of one another. They are also neither the necessary, nor the sufficient condition for one another.