File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Hashtables are synchronized... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Hashtables are synchronized..." Watch "Hashtables are synchronized..." New topic
Author

Hashtables are synchronized...

Muralidhar Gandepalli
Greenhorn

Joined: Apr 13, 2001
Posts: 13
Can some one throw light on why Hashtables are called synchronized ...
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Most all of Hashtable's methods are synchronized to make them (mostly) thread-safe. If you don't need thread-safety (or need finer-grained control), HashMap is your friend. Java 1.5 also added ConcurrentHashMap (or some similar name) that I believe allows multiple readers simultaneously.
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

I don't know why they chose to synchronize it. Its synchronization is not going to preclude your own synchronization. IMHO its a design flaw and a waste of time for them to have done that.

I welcome other opinions.
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by CL Gilbert:
I don't know why they chose to synchronize it.
I'd bet five bucks it was a simple matter of the early Java developers at Sun going hog-wild: "Man, it's so cool having synchronization built into the language. I wonder where else I can use it?"
Sathvathsan Sampath
Ranch Hand

Joined: Oct 03, 2000
Posts: 96
Most of time you end up with client level sychronization and would find that hashtable don't really help. HashMap serves you then.


- Sathvathsan Sampath
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Yes but hashtable and hashmap are not interchangeable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hashtables are synchronized...
 
Similar Threads
Synchronized collection
Why is HashTable considered historic?
how about using hashtable as method arg....
Synchronized in ejb
How To Get Rid Of java.util.ConcurrentModificationException?