These properties applies to java collections and difference from synchronized collection to un-synchronized collections.
In case of fail-safe property, the iterator working on a collection works on the clone of a collection rather than working on the actual collection. Due to this even if there is a change in the underlying collection it is not affected and hence fail-safe iterator will never throw a ConcurrentModificationException. By design all the collection that comes under java.util.concurrent package are fail-safe.
On the other hand in case of fail-fast property, the iterator works directly on the collection. So every time we try to get next element from the collection it will check for modification and if found will throw ConcurrentModificationException. This property applies to all the collection that comes under java.util package.
Comments
Post a Comment
.