Volatile vs Atomic

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

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:


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

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