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

Doug Lea dl@cs.oswego.edu
Mon, 12 Jan 2004 20:19:07 -0500


> and take the risk that if 
> there is an object in a hashtable and its value changes, it may
> may not be findable using the same key value as before.

Under the current scheme, anyone who want to use an AtomicInteger
with value-based semantics as a key in a hash table, only has
to say "get()"

  table.put(myAtomicInteger.get(), something); // value-based

 versus, for identity-based, table.put(myAtomicInteger, something); 

Autoboxing takes care of the rest in the value case. And there's no
risk in not finding it again in case the variable changes value.
Similarly for contexts using Comparable.

What could be nicer? :-)

-Doug