A rapid failure (fail-fast)
-
Principle
when traversing a collection iterator, iterator maintains a modCount variable, when traversing a front element, it will determine whether the value modCount expectedModCount, if it is expectedModCount through the results returned; otherwise, an exception is thrown ConcurrentModificationException terminate traversal. -
HashMap rapid failure of
the HashMap Iterator iterator is a quick failure.
When traversing a collection, if the modification (add, delete, change) of the elements of the collection, exception is thrown ConcurrentModificationException
II. Security failure (fail-safe)
-
Principle
iterator while traversing the collection, the first copy of the original elements of the set, and then the copy of the collection to traverse. Therefore, when traversing, the original set of modifications is not detected by the iterator. -
Security failure of Hashtable
Hashtable Enumerator iterator uses the security fails.