Thursday, December 2, 2010

Question :Please explain Hashtable vs ConcurrentHashMap.

Answer : Hashtable and ConcurrentHashMap are both thread safe, but these classes have different implementations. ConcurrentHashMap is faster than Hashtable, the main difference is that Hashtable uses one lock for all map, but ConcurrentHashMap uses one lock per bucket therefore several threads can modify the map without blocking.