unsynchronized access to primitive variables

luka8088 luka8088 at owave.net
Sat May 19 01:16:39 PDT 2012


Hello to all,

I would like to know if D guarantees that access to primitive variable 
is atomic ?

I was looking for any source of information that says anything about 
unsynchronized access to primitive variables. What I want to know is if 
it is possible (in any way and any OS / hardware) for the following code 
to output anything other then 1 or 2:

import std.stdio;
import core.thread;

void main () {
   int value = 1;
   (new Thread({ value = 2; })).start();
   writeln(value);
}

Thanks !


More information about the Digitalmars-d-learn mailing list