This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Synchronized HashMap   Vs   Hashtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Synchronized HashMap   Vs   Hashtable" Watch "Synchronized HashMap   Vs   Hashtable" New topic
Author

Synchronized HashMap Vs Hashtable

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Which one is beeter Synchronized HashMap / Hashtable ? because Hashtable is defaultly Synchronized?
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
HashMap implementation is not synchronized. Hashtable is. It really depends on the situation that you've to decide which is a better choice. But, being synchronized has a little trade-off in performance.

You could instead synchronize the method or code block that accesses the HashMap object instead.

HTH.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Jayaraj Sekaran
Greenhorn

Joined: Apr 17, 2005
Posts: 5
You can actually go for HashMap itself.

The advantages of HaspMap are:
1) Not synchronized
2) Can have 'Null' as value
3) Can have 'Null' as a key also.


SCJP 1.4<br />SCWCD 1.4<br />WSAD 5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized HashMap Vs Hashtable
 
Similar Threads
Hashtable vs HashMap
HashMap vs. Hashtable
HashMap and HashTable
HashMapDefinition
xml parsing.