Hashtable Should Be Deprecated
The “Hashtable” has always been a thorn in my side. Well not the class itself, but the people who used it all the time instead of “HashMap”. “HashMap” is the god damn standard implementation. If you really need a synchronized Map, you have to be anyway extremely carefull what you’re doing.
Now, since Java 5.0, there is a better thread-safe implementation of an Map, called “ConcurrentHashMap” in the java.util.concurrent-package. It is way better than the “Hashtable”, because it doesn’t just block on every operation. It uses smart algorithms to lock only if really needed.
So in my opinion, the “Hashtable” doesn’t have any great use anymore. So I think “Hashtable” should be marked as deprecated.
- Projects and Stuff
- Java Generics an Google Juice Tricks
Nice article. ConcurrentHashMap is indeed best choice in case of multithreaded environment if numbers of reader is much greater than number of writer to avoid contention and to increase throughput and performance.