Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: synchronized HashMap vs. HashTable

Reply
Thread Tools

Re: synchronized HashMap vs. HashTable

 
 
Arne Vajh°j
Guest
Posts: n/a
 
      05-21-2008
Mikhail Teterin wrote:
> I need multiple threads to be able to operate on the same Map. The HashMap's
> documentation at
>
> http://java.sun.com/javase/6/docs/ap...l/HashMap.html
>
> advises the following construct:
>
> Map m = Collections.synchronizedMap(new HashMap(...));
>
> However, the HashTable is, supposedly, inherently thread-safe.
>
> What's better? I saw somewhere, that HashTable is a "legacy" class -- is
> that true?


Yes.

Since December 1998 HashMap has been the recommended solution
over Hashtable.

Most developers will expect to see HashMap, so I would recommend
using that - even though it does not have any real impact.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: synchronized HashMap vs. HashTable Knute Johnson Java 9 01-05-2011 02:53 PM
Synchronized Block v.s. Synchronized Method Jerry Java 4 08-11-2010 02:34 PM
Re: synchronized HashMap vs. HashTable Mark Space Java 0 05-21-2008 10:31 PM
synchronized block in synchronized static method dmcreyno Java 9 06-27-2006 07:43 PM
Use of synchronized variables over synchronized methods? Pep Java 6 08-15-2005 01:29 PM



Advertisments