[concurrency-interest] Basic thread safety question: final/volatile/synchronized fields

Jeremy Manson jmanson at cs.umd.edu
Wed Dec 20 13:05:26 EST 2006

Kessel, Chris wrote:

> The default in a lot of code, and my default for years, has been to
> declare object fields "private Foo _f;" in objects that end up being
> used in multi-threaded contexts.  Based on my understanding now, that
> can't be a thread-safe field (unless used in synchronized blocks).

This is a misconception I have never heard, so I'm thinking there must 
be more to it.  A private qualifier has no effect on threading 
whatsoever.  All it means is that (coarsely) you can't access that field 
directly from outside the object.

"Thread-safe" being something of an imprecise term, what effect did you 
think it had on threading?


More information about the Concurrency-interest mailing list