InterviewSolution
| 1. |
What Is A Fail-safe Iterator? |
|
Answer» An iterator is considered fail-safe if it does not throw ConcurrentModificationException. ConcurrentModificationException is not THROWN as the fail-safe iterator makes a copy of the underlying STRUCTURE and iteration is done over that snapshot. SINCE iteration is done over a copy of the collection so interference is IMPOSSIBLE and the iterator is guaranteed not to throw ConcurrentModificationException. An iterator is considered fail-safe if it does not throw ConcurrentModificationException. ConcurrentModificationException is not thrown as the fail-safe iterator makes a copy of the underlying structure and iteration is done over that snapshot. Since iteration is done over a copy of the collection so interference is impossible and the iterator is guaranteed not to throw ConcurrentModificationException. |
|