[concurrency-interest] Simple ScheduledFuture problem

Dhanji R. Prasanna dhanji at gmail.com
Wed Aug 30 20:34:45 EDT 2006

On 8/31/06, Dawid Kurzyniec <dawidk at mathcs.emory.edu> wrote:
> Just my 2c (to explicitly point out what David and Brian smuggled
> between the lines): the synchronization on setter can only be skipped if
> there are no other setters.
> It is tempting to drop "synchronized" from set(newValue), but it would
> be wrong: it would break atomicity of read-modify-write methods such as
> getAndAdd etc. by allowing set(newValue) to perform the update in the
> middle.

yes, but presumably a more elegant solution is for the other "setting
methods" to invoke the single setter, and treat the volatile field as
a javabeans property.

Just my 20c that we should be encouraging this approach. =)

> Regards,
> Dawid


More information about the Concurrency-interest mailing list