[concurrency-interest] Constructors of AtomicXXX and AtomicXXXArray

David Holmes dholmes@dltech.com.au
Thu, 8 Jan 2004 10:07:56 +1000


Olivier,

> The AtomicXXXArray classes do not have a constructor taking an array
> of XXX (Integer/int or equivalent).

I have not encountered a context where there is a need to initialize
an atomic "array" from an existing array. That's not to say it doesn't
exist, but there are no use cases that highlighted the need for it. Do
you have an actual use case for this?

> AtomicXXX constructors accept only a single primitive
> argument at this time.
> If you look at Number(s) (even if I am not interested in
> extending Number)
> you will see constructors taking a String and parsing it.

 new AtomicInteger(Integer.parseInt(theString, theRadix))

There's no need to burden a class with conversion facilities when the
conversions already exist (and in a fuller form) elsewhere.

> I am not knowledgeable about auto(un)boxing (the link below
> seems old)
> but I see nothing about automated String parsing (String ->
> some primitive type)
> http://www.jcp.org/aboutJava/communityprocess/jsr/tiger/auto
> boxing.html
>
> Your opinion about the usefulness of this ?

String parsing typically has application specific error-handling
associated with it, so you're much better off doing the conversion
yourself. Just my opinion.

David Holmes