Home  >  Forum  >  Core Java
Post New Query

How does java ConcurrentHashMap handles concurrency


joined on
December 28,2013
Asked on March 26,2014
HI All,
How does  java ConcurrentHashMap  handles concurrency internally?

Thanks
joined on
March 14,2013
Replied on April 02,2014

ConcurrentHashMap implements   Segment class.  Segment class behaves like a  hashtable and  is synchronized using RetrantLock. Retrieval of content from ConcurrentHashMap does  not implement locking. But it returns the most updated value. While putting value in ConcurrentHashMap,  it follows the below steps.


1. Check for null value, if null throw exception.

2. Create hash code

3. Get the segment table for the hashcode

4. Put the value


Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us