Java’s java.util.Hashtable has the same functionality as java.util.HashMap. Their main difference is that Hashtable is thread-safe and synchronized while HashMap is not. As of JDK5, we have ConcurrentHashMap which can be used for multi-thread context. It has better performance than Hashtable. So do we have any reason to use Hashtable in the future?
Java’s java.util.Hashtable has the same functionality as java.util.HashMap . Their main difference is that
Share
Reverse compatibility is the only reason
Hashtableis still in the JDK.Also, another alternative to
Hashtableis aCollections.synchronziedMap.