|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? Thanks.
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? Thanks. Usually not, unless you cache static data that is initialized lazily (i.e. loaded when it becomes available first, afterwards it is only read, never updated). If you do not need any cached data (used by the entire application, regardless of request/session), there is no real need for hashtable. If you have cached data that is read on initialization (during the servlet's init() method), there is no real need for hashtable. In both cases hashmap is fine. (this does not deal with any clustering of web-servers and such. I assume that data can be cached statically)
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? The Hashtable class was created before the current Collection API was designed. There's really no reason to ever use Hashtable anymore except for interacting with existing code which uses a Hashtable. If you need a synchronized version of HashMap, you can get it by calling Map syncedMap = Collections.synchronizedMap(new HashMap()); Adam
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? Thanks. Whether or not you provide thread safety to the data held by the structure is entirely up to how you access (read/write) it. If you need thread safety, the Collections way (as opposed to the old Hashtable way) of doing that is: Map m = new Collections.synchronizeMap(new HashMap());
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? The Hashtable class was created before the current Collection API was designed. There's really no reason to ever use Hashtable anymore except for interacting with existing code which uses a Hashtable. If you need a synchronized version of HashMap, you can get it by calling Map syncedMap = Collections.synchronizedMap(new HashMap()); Adam
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
difference between hashmap and hashtable? difference between hashmap and hashtable
|
|
|
A hashmap is not synchronized and faster than hashtable. In a servlet application when you have httpsession to take care of session independance, is there any reason that I should use hashtable over hashmap? The Hashtable class was created before the current Collection API was designed. There's really no reason to ever use Hashtable anymore except for interacting with existing code which uses a Hashtable. If you need a synchronized version of HashMap, you can get it by calling Map syncedMap = Collections.synchronizedMap(new HashMap()); Adam Hi Adam, Why shouldn't you use Hashtable if you need a synchronized (hash-)map? The class nor its methods are deprecated. And the Collections.synchronizedMap(...) creates an extra _object_ (implementing Map) as a wrapper around the input-map. Why would you want to do that, if you have a perfectly good Hashtable lying around?
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|