Google News
logo
Full Stack Developer - Interview Questions
Compare fail-fast and fail-safe iterators?
Basis of Comparison Fail Fast Iterator Fail Safe Iterator
Operates It operates directly on the collection itself. It operates on a cloned copy of the collection.
Exception It throws a ConcurrentModificationException in modifying the object during the iteration process. It does not throw Exception.
Clone Object No clone object is created during the iteration process. A copy or clone object is created during the iteration process.
Memory utilization It requires low memory during the process. It requires more memory during the process.
Modification It does not allow modification during iteration. It allows modification during the iteration process.
Performance It is fast. It is slightly slower than Fail Fast.
Examples HashMap, ArrayList, Vector, HashSet, etc. CopyOnWriteArrayList, ConcurrentHashMap, etc.
Advertisement