[concurrency-interest] CopyOnWriteArrayList.setAll?

David Holmes davidcholmes at aapt.net.au
Thu Apr 23 20:39:16 EDT 2009


> Perhaps Doug can explain why this backwards incompatible change was
> made?

The synchronization mechanism is an internal implementation detail not part
of the specification. None of the j.u.c utilities support a means to create
extenerally defined atomic operations.

The change was made for potential performance reasons, and a number of
JSR-166 members had argued for a consistent approach to using j.u.c
utilities within j.u.c ("eat our own dog food").

Cheers,
David Holmes

> -----Original Message-----
> From: concurrency-interest-bounces at cs.oswego.edu
> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of Jed
> Wesley-Smith
> Sent: Friday, 24 April 2009 8:22 AM
> To: Sam Berlin
> Cc: concurrency-interest
> Subject: Re: [concurrency-interest] CopyOnWriteArrayList.setAll?
>
>
>
> Interesting. In the Java5 version the modifications are protected by
> COWArrayList's monitor - synchronized(this) - so you simply need to
> acquire that object's monitor - synchronized(cowList) and and  call
> clear(), addAll().
>
> In later versions however it has been changed to use a private
> ReentrantLock - so that approach will break. There doesn't appear to
> be any way to access that lock externally or from a sub-class.
>
> Perhaps Doug can explain why this backwards incompatible change was
> made?
>
> cheers,
> jed.
>
> On 24/04/2009, at 7:45 AM, Sam Berlin wrote:
>
> > Hi Folks,
> >
> > Is there a way to emulate a CoW "set all" with
> > CopyOnWriteArrayList?  The goal is to make it impossible for someone
> > to view the list in a state except for where all the new items are
> > added and all the old ones are removed.
> >
> > It doesn't seem like it's possible (without restoring to blocking &
> > copying the data within the locks), but I may be missing something.
> > If I'm not missing something, would setAll be a good candidate for
> > inclusion into CoWArrayList?
> >
> > Sam
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at cs.oswego.edu
> > http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest




More information about the Concurrency-interest mailing list