Should Interlocked.CompareExchange also a volatile variable?
No, volatile wouldn’t be helpful at all, and certainly not for this reason. It would just give that first read “acquire” semantics instead of effectively relaxed, but either way will compile to similar asm that runs a load instruction. if you get a dirty value from a CPU cache CPU caches are coherent, so anything … Read more