[concurrency-interest] Re: AtomicInteger and AtomicLong should implement Number

David Holmes dholmes@dltech.com.au
Wed, 14 Jan 2004 08:34:46 +1000


Just 2c on one aspect of this:

> Gregg Wonderly wrote:
> Performance is not the primary issue here.  The primary
> issue for me is
> that I am going to have to synchronize through memory allocation to
> create all these new objects.  I am also going to expand the JVM's
> memory use to have to representations of the same thing.
> There seems little advantage to this.

Isn't this argument a bit overstated given that you must change your
applications to use AtomicInteger anyway?

If you currently use "int" values as your mutable entities you would
have to wrap these as Integer at some stage. Now you would use
AtomicInteger and still have to wrap at the same stage.

If you currently use Integer objects and perform calculations then you
must be creating new Integer objects for results. Replacing Integer
with AtomicInteger can remove the need for intermediate Integer
objects, but you still need the final Integer to hold the result from
get().

Anyway this point is moot now that AtomicInteger will extend Number.

David Holmes