Volatile vs Atomic


#1

To my understanding , if I have one writer thread and one reader thread, I can use volatile but if I have more than 1 writer thread then I should only use
Atomic / ScopedLock.

Is that correct?

Thank you


#2

Since you are asking this question I recommend you only ever use a ScopedLock for multi-threaded stuff as anything else is dangerous and requires in depth knowledge of lots of complex issues. To get you started with some of these issues have a read of this:

https://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming


#3

As an introduction concerning atomicity there's a bunch of interesting articles in that blog:

( http://preshing.com/20130618/atomic-vs-non-atomic-operations/ ).