[concurrency-interest] Fixed size CopyOnWriteArrayList vs array concurrent access.
tim at peierls.net
Tue Oct 31 11:37:39 EST 2006
COWAL is most appropriate when writes are infrequent.
I think the simplest approach in your case is an array of thread-safe
value-holders. You could use SynchronizedRef from Doug Lea's
util.concurrentpackage, or AtomicReference from Dawid Kurzyniec's
backport. Or just roll
Note that this only deals with concurrent access of the elements as opaque
values. It does not address the issue of whether the element values
themselves refer to thread-safe objects; if they do not, then two threads
might safely obtain the value of the first element in the array only to
unsafely call methods of the object referred to by that value.
On 10/31/06, Eugene Gordienko <egordienko at yahoo.com> wrote:
> Hi All,
> We use java 1.4. We have a use case: fixed size array of objects and need
> concurrent access to its elements: almost even number of reads and
> writes, also some iterations. The size may be less than 10 but may be more
> than 100.
> So my choice was fixed size CopyOnWriteArrayList (COWAL) ... but my
> collegues' argument is: when we wrie to COWAL the chunk of it is locked
> while in case of array of objects we can lock just on one array element.
> What is your experience/suggestion?
> Many thanks,
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest