Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2005

Tip: Looking for answers? Try searching our database.

concurrent and atomic map?

Thread view: 
Daisy - 02 Dec 2005 19:39 GMT
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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.