[concurrency-interest] Constructors of AtomicXXX and AtomicXXXArray

David Holmes dholmes@dltech.com.au
Thu, 8 Jan 2004 11:11:22 +1000

Olivier Dupuy wrote:
> No I don't have a use case at this time but why would you
> like to create an AtomicIntegerArray if you don't populate it after
> ints, shortly or not.

Because the initial value of zero is all I need :) Consider using an
AtomicIntegerArray for per-thread counters. Each worker thread
increments an AtomicInteger based on that thread's index on each task
it completes. A management thread goes through and checks the counts,
perhaps changing some internal settings based on what it finds. Zero
is the only initialization I need in that case.

> This is my point. Who would populate this array ?

The thread that creates it can populate it using a loop before
publishing the reference.

We're trying to avoid unnecessary/inessential changes to the API's at
this late stage of the game - hence the request for a use case - but
I've been informed that "we" should have thought of this anyway and
that it may be more efficient to internalize the array initialization.
Hence your suggestion seems to have been accepted.


David Holmes