[concurrency-interest] Simple ScheduledFuture problem
dcholmes at optusnet.com.au
Tue Aug 22 20:12:51 EDT 2006
> so the volatile field cant be read when a thread is in its
> synchronized setter?
Yes it can, but the assignment in the setter is atomic so the semantics are
"as if" the read occurred just before or just after the synchronized
It's a degenerate case of a read/write lock. You never have to exclude the
writer with respect to the reader because the action of the writer is atomic
with respect to the reader anyway. Of course that breaks down if more than
one assignment were involved.
> On 8/23/06, David Holmes <dcholmes at optusnet.com.au> wrote:
> > > Dhanji R. Prasanna writes:
> > > Im curious, what is the purpose of declaring flag volatile AND
> > > synchronizing setter access to it?
> > It gives you a simple/crude read/write lock.
> > David Holmes
More information about the Concurrency-interest