[concurrency-interest] Concurrent sequential access to a mutable field without the volatile modifier

Sébastien Bocq sebastien.bocq at gmail.com
Fri Jan 7 10:32:22 EST 2011

2011/1/7 Mark Thornton <mthornton at optrak.co.uk>

> On 07/01/2011 15:01, Sébastien Bocq wrote:
>> Hello,
>> I made a simple test (see below) to verify my assumption that a variable
>> mutated sequentially by multiple threads must be marked as volatile to have
>> mutations visible across these threads. How comes my test succeeds even
>> though I omitted the volatile keyword?
> The absence of volatile merely means the mutations may not be visible, it
> doesn't guarantee that they won't be visible. So in some implementations
> your mutations may be visible while in others they may not. Adding volatile
> gives you a guarantee of visibility.
Ok, I needed to be sure.

Thanks for the swift answer,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20110107/2b6f357c/attachment.html>

More information about the Concurrency-interest mailing list