I'm confused by the concurrent map offering for Java 1.5. Ideally, I
would like to use primitive long keys in a
java.util.concurrent.ConcurrentHashMap. There is a constructor
ConcurrentHashMap(Map<? extends K,? extends V>t ). Is it possible to
use a primitive type as a key in ConcurrentHashMap?
Alternatively, I have used the gnu maps that allow primitives.
Thanks
Oliver Wong - 02 Dec 2005 19:41 GMT
> I'm confused by the concurrent map offering for Java 1.5. Ideally, I
> would like to use primitive long keys in a
[quoted text clipped - 3 lines]
>
> Alternatively, I have used the gnu maps that allow primitives.
As far as I know, it's not possible. The keys of the map must be an
Object (or something which extends Object), and not a primitive. What you
can do is box your longs into Long objects. Java 1.5 will do this
automatically for you if you try to supply a primitive long.
- Oliver
Roedy Green - 02 Dec 2005 20:20 GMT
>Is it possible to
>use a primitive type as a key in ConcurrentHashMap?
you can use Longs then use autoboxing unboxing.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.