[concurrency-interest] Elements in AtomicReferenceArray and AtomicReference[] both distinct?

Chris Vest mr.chrisvest at gmail.com
Wed Aug 1 12:03:42 EDT 2012


Hi Raph,

You are more likely to run into false sharing (cache-line contention) with
AtomicReferenceArray, when threads concurrently write to element indices
that are close to each other, than you are with an array of AtomicReference
objects. On the other hand, the latter uses more memory.

The implementation of ARA does not use locks:
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/atomic/AtomicReferenceArray.java?revision=1.42&view=markup


On 1 August 2012 17:24, Raph Frank <raphfrk at gmail.com> wrote:

> I always assumed that elements in an AtomicReferenceArray were
> distinct.  Threads that accessed different elements would not
> interfere.
>
> This thread suggests otherwise, that the protection is at the entire
> array level.
>
>
> http://www.java-forums.org/threads-synchronization/25324-atomicreferencearray-t-equivalent-array-atomicreference-t.html
>
> Which is correct, do an array of AtomicReferences give better concurrency?
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120801/980808be/attachment.html>


More information about the Concurrency-interest mailing list