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

Gregg Wonderly gregg.wonderly@pobox.com
Tue, 13 Jan 2004 19:07:58 -0600

Dawid Kurzyniec 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.
> Unless you use some sort of a GUI (and if you did you'd not worry about
> memory footprint of number wrappers), you probably don't need to create
> wrappers at all, just use primitive values returned by get() -- this
> induces no memory allocation whatsoever. 

I have existing code that has the following logic in it.

	if( NumberImpl1.equals(NumberImpl2) ) {

How am I going to reuse this code without doing

	new Integer( AtomicInteger1.intValue() )

some place so that the equals will work with value based comparison?