I referred many links regarding Iterator of ConcurrentHashMap, like Is iterating ConcurrentHashMap values thread safe? or any other on Google, even java doc,yet i am not much getting what kind of behavior i might face while iterating the Concurrenthashmap and simultaneously modifying it
Read the JavaDoc for ConcurrentHashMap.values()
:
The view's iterator [..] guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.
If you're interested in the contract of the other iterators, they have documentation as well.
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