On Tue, Mar 5, 2013 at 1:58 AM, David Paterson <dnpaterson@xxxxxxxxx> wrote: > On 5 March 2013 09:40, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote: > >> volatile is not for multithreading, you need proper synchronization >> for interthread communication. > > Not always. For very simple, non-critical uses you can just use a > volatile flag-type variable. Cheap and nasty, I agree, but useable. If your code has a race condition before you add a volatile qualifier, it will still have a race condition after you add the qualifier. If you want a simple flag variable, don't use volatile; use __atomic_load and __atomic_store. Ian