Java / Concurrent collections
Is Iterator of ConcurrentHashMap fail-safe or fail-fast?
Iterator of ConcurrentHashMap is a fail-safe iterator so it will not throw a ConcurrentModificationException, eliminating the need to lock the map during iteration. The iterator returned by ConcurrentHashMap are also weakly consistent so if the Map is modified during iteration, it may or may not reflect the recent modification. Usually, it creates a copy of collection before iterating.
More Related questions...