[concurrency-interest] Significance of volatile for Objects
alarmnummer at gmail.com
Fri Mar 7 05:51:46 EST 2008
Under the condition that no writes are made after the initialization,
you are completely right.
On Fri, Mar 7, 2008 at 11:23 AM, Mark Thornton <mthornton at optrak.co.uk> wrote:
> Peter Veentjer wrote:
> > PS:
> > I know you made the remark, but for other less experienced developers
> > reading this thread.. the example is not threadsafe because HashMap is
> > not threadsafe. So its internal structure could be corrupted by
> > concurrent access.
> I think it would be safe provided no writes to the HashMap happen after
> the volatile assignment, and that it was safely created prior to that
> point. There are Map's which aren't threadsafe even for reading, but as
> far as I know HashMap is not one of them.
> Mark Thornton
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
More information about the Concurrency-interest