In practice, undefined behavior is unpredictable because compiler does optimization with the assumption that you do not have undefined behavior. When you do have them, the optimization won&#x27;t preserve the &quot;as-if&quot; rule.<p>The same applies to Java&#x2F;C# when data race is present. The JIT must be generating optimized codes assuming that no data race occurs, because it is impossible to detect or correct them (at least in current implementation). When you do have data race, the bugs will be as subtle and Schrödinger&#x27;s as if data race occurs in a C program.