pranjal thakur pranjal thakur - 28 days ago 14
Java Question

Why Does HashTable still in existence in Java, when ConcurrentHashMap is more efficient than it?

As far as I know ConcurrentHashMap partitions the buckets and has separate locks on each partition. But the HashTable has one single lock for all buckets.

As a result the ConcurrentHashMap can be either more efficient or (in worst case )equally efficient as HashTable. So why does Java needs to keep HashTable in its latest versions.

Isn't HashTable obselete now? Or are there still some pros HashTable has over ConcurrentHashMap?

Answer

A very simple reason: there might be zillions of lines of code using that classic. And people that would like to recompile that code using a newer JDK.

You want to break all of them!?

Comments