If I don’t care whether Thread1 changes Flag1 at the same time Thread2 changes Flag1, is there anything else to worry about besides logic errors? Will it cause a crash etc if:
Thread1andThread2readFlag1at the exact same time?Thread1is writing toFlag1at the same time asThread2is readingFlag1?
In these examples, Flag1 is a bool.
According to the rules of the C++11 memory model:
A data race is undefined behaviour. Although it’s unlikely to crash on any sane hardware, it’s undefined behaviour, so anything could happen.