Lets see what are the differences we can see in HashMap and Hashtable.
1. Synchronization :
Hashtables are synchronized , it means at one point of time only one thread can modify a Hashtable. i.e any thread before performing an update on a hashtable will be acquiring a lock on the object while others will wait for lock to be released.
Hashmap is not synchronized , but we can make it synchronized.
Iterator of HashMap is fail-safe but the enumerator for the Hashtable is not fail-safe. Lets see what exactly fail-safe is. If an iterator has been created on a collection object and some other thread tries to modify this object , a concurrent modification exception will be thrown. So fail safe is like ability of system to fail but it wont produce some catastrophic results.
3. null values
Hashtable doesn't allow null but Hashmap allows null values.
What are the differences between HashMap and Hashtable?
20:51:00 Collections , Core Java , Difference Between , differences between HashMap and Hashtable , HashMap , Hashtable , synchronized Edit