Fail-Fast iterators
- works on the original collection
- doesn't allow modifications to the collection by any other means except the methods provided by the iterator, otherwise throws ConcurrentModificationException
- has methods like add() and remove() for ListIterator and remove() for Iterator to modify the collection
- thread safety is an issue if the collection gets modified externally
Fail-Safe iterators
- works on a snapshot of the collection
- doesn't allow collection modification operations like add() and remove() and as a result doesn't throw ConcurrentModificationException
- if any collection modification operation is performed, UnsupportedOperationException is thrown
- thread safety is not an issue
Comments