Do we need a hashtable since we have a ConcurrentHashMap?

Java java.util.Hashtablehas the same functionality as java.util.HashMap. Their main difference is that it Hashtableis thread safe and synchronizes, but HashMapnot. With JDK5 we have ConcurrentHashMapthat can be used for multi-threaded context. It has better performance than Hashtable. Do we have any reason to use it Hashtablein the future?

+3
source share
2 answers

Backward compatibility is the only reason it Hashtableis still in the JDK.

In addition, another alternative Hashtableis Collections.synchronziedMap.

+5
source

, HashTable. , , .

0

All Articles