[concurrency-interest] Volatile happens before question
vitalyd at gmail.com
Tue Jan 17 18:31:58 EST 2012
No. You lost the transitive relationship of happens-before with your second
statement. Your code can be reordered and executed as follows:
Thread 1 Thread 2 if (!a) // sees false a = true b = 1; bStore =b; print //
This actually isn't valid because in original code nothing would print if a
is false - it doesn't enter the if block. However, compiler can simply
move b=1 before a =true as that's permissible and maybe it'll do that for
some register allocation purposes, as an example.
Sent from my phone
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest