Re: Differences between 'Hashtable' and 'Map'
Friday, November 30, 2001 05:21 AM
first of all, Map is an interface while Hashtable is a concrete class. so you are better of comparing Hashtable and HashMap classes. the difference between them is that HashMap class is not synchronized while Hashtable class is. To get HashMap to be synchronized, you have to make the following call
Map m = Collections.synchronizedMap(new HashMap(...));. so if you do not care about synchronized access to the collection (such as cases where collection is keeping read-only data) you should use HashMap because you eliminate the overhead of synchronization on access to the collection. if data in the collection is not read-only and is accessed by many threads and you want to preserve data integrity in the collection, you should use Hashtable.