util. concurrent package such as ConcurrentHashMap, CopyOnWriteArrayList, etc. are Fail-Safe in nature. … The default iterator for the ConcurrentHashMap is weakly consistent.
Which iterator is fail-safe?
Base of ComparisonFail Fast IteratorFail Safe IteratorPerformanceIt is fast.It is slightly slower than Fail Fast.ExamplesHashMap, ArrayList, Vector, HashSet, etcCopyOnWriteArrayList, ConcurrentHashMap, etc.
What are fail fast and fail-safe collections?
Fail-safe iterators means they will not throw any exception even if the collection is modified while iterating over it. Whereas Fail-fast iterators throw an exception(ConcurrentModificationException) if the collection is modified while iterating over it.