• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashTable Synchronized

 
Yog Ananth
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the necessary for all the legacy classes synchronized, any special use for that
 
Henry Wong
author
Sheriff
Posts: 22524
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By legacy, I am assuming you mean JDK 1.0 container classes.

Good, bad, or indifferent, JDK 1.0 container classes were synchronized to allow threadsafe access. As for why they are still synchronized, I am assuming it is to be backward compatible.

Henry
 
Ed Wallen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, you should use those objects provided in the new Collections API (since 1.2). If you need a collection implementation to be threadsafe, use the java.util.Collections class. Collections consists exclusively of static methods that operate on or return collections. The methods that begin with "syncronized" will return you a threadsafe collection implementation (list, set, map, etc.).

-Ed
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!