Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hashtable and HashMap Synchronization  RSS feed

 
James Davison
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you synchronize on a HashMap object, is there any difference (at that point) between a Hashtable and a HashMap? If so, please explain.
Also, for a Hashtable (or a synchronized HashMap) object, should you synchronize on an Object contained with the map prior to updating its contents? If so, would it be better to synchronize the method on the Object that updates the contents?
 
Warren Dew
blacksmith
Ranch Hand
Posts: 1332
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The synchronized HashMap would still permit nulls, which the Hashtable doesn't. The Hashtable would still support some older methods that the HashMap doesn't (such as the elements() method).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!