I was reading the article "Java theory and practice: Building a better HashMap" that gives an excellent overview about the implementation of ConcurrentHashMap.
I also found some discussions over it on Stackoverflow here.
I question though I had in my mind is "what are the scenarios/applications/places" where ConcurrentHashMap is used.
Thank you
You would use a ConcurrentHashMap
in the same instances you would use a HashMap
, except that you plan on more than one thread using the map.
I use it for quick lookup from user ids to user objects in a multi-threaded server for instance.
I have a network-thread, a timer thread for periodical tasks and a thread for handling console input. Multiple threads access the hash map of users, thus it needs to be thread safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With