I have a question about the following code sample (m_value isn\'t volatile, and every thread runs on a separate processor)
void Foo() // executed by thr
The interlocked exchange operations guarantee a memory barrier.
The following synchronization functions use the appropriate barriers to ensure memory ordering:
Functions that enter or leave critical sections
Functions that signal synchronization objects
Wait functions
Interlocked functions
(Source : link)
But you are out of luck with register variables. If m_value is in a register in Bar, you won't see the change to m_value. Due to this, you should declare shared variables 'volatile'.