[concurrency-interest] Concurrent Read/Write without Synchronization

Insane Membrane mettafort at gmail.com
Fri Dec 17 21:29:21 EST 2010


Could someone please answer this simple question for me? I have two threads,
A and B, and they share an object P that has an integer property called x.
 The first question is, if A sets x to a value, but B only ever reads x,
will B ALWAYS see the latest value of x?  So A does x = x + 1.  Will B
always see x with the new value? We were under the impression the latest
value could still be sitting in the cache of A, but not visible in B.  This
would be one reason for the volatile or interlocked operations?  Similarly,
if we have an object reference and we set it onto some public/global
reference, all threads would always see whatever had been written to this
global reference IMMEDIATELY, without any needs for synchronization or

This is assuming the int is 32bit on a 32bit machine, and the reference is
the same too.

Thank you,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20101217/a218b810/attachment.html>

More information about the Concurrency-interest mailing list