This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
by default hashtable gives synchronization; why they have written Collections.synchronizedMap(new HashMap());
whta benefits will it give?
It has to do with history... The hashtable map was available right from the beginning -- and it was thread safe. With java 1.2, they added a huge set of collections, and decided to let the developer decide whether it should be synchronized -- hence, the collections class. They can't change the fuctionality of hashtable, or older programs will break.
Besides, there are different types of hashmap classes, tree, sorted, etc., that can be synchronized by the collections class.