[concurrency-interest] Concurrent sequential access to a mutable field without the volatile modifier
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:
>> 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...
More information about the Concurrency-interest