3 ms·
Javas HashMap<K,V> has no checking for concurrent modification at all, it's only a check that is made during Iteration In the internal HashIterator type. It onl
by alkonaut 11y ago
Javas HashMap<K,V> has no checking for concurrent modification at all, it's only a check that is made during Iteration In the internal HashIterator type. It only checks that the collection wasn't modified while that iterator was iterating.
There is nothing there to prevent the HashMap itself from corrupting completely with multiple writers, or from data racing while fetching single items on multiple threads.
So there is no way you can use the ConcurrentModificationException as a way of ensuring that your HashMap is actually working in a concurrent scenario, it only handles one scenario: reads, and even only reads when iterating.