Archive for February, 2011

Discover the power

ConcurrentHashMap of EhCache´╗┐ vs HashMap vs ConcurrentHashMap

The benefits of java.util.concurrent.ConcurrentHashMap over a regular synchronized HashMap become blatantly apparent when we run a small experiment to simulate what might happen in the case of a map used as a frequently-accessed cache on a moderately busy server. See the details at http://www.javamex.com/tutorials/concurrenthashmap_scalability.shtml

But here is the problem http://www.informit.com/guides/content.aspx?g=java&seqNum=246

The truth

A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable. However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any support for locking the entire table in a way that prevents all access. This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details.

Try and get the latest of version of ConcurrentHashMap of EhCache instead of java.util.concurrent.ConcurrentHashMap.

Advertisements

Leave a Comment