java - Hashtable vs HashMap performance in single threaded app -
i know hashtable synchronized safe used in multithread app , hashmap not.
i wondering if there performance difference between these 2 in single thread app.
(or, when use 1 on other?)
if want thread safe collection can use concurrenthashmap or collections.synchronizedmap() linkedhashmap or hashmap. if don't need thread safe collection can use last two. hashtable has been retro fitted support map generics comes alot of legacy methods same thing or same thing.
hashtable can used, imho using 1 of many other options have been developed later cleaner solution. if have library needs hashtable, need use it, otherwise use class need, follows best practice minimum of legacy methods.
the performance difference 0.5 per call. may or may not significant.
however, if don't need type thread safe, there no reason use synchronized version. if need type thread safe, can't use type not without thread safety guard.
Comments
Post a Comment