Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is a fail-fast iterator?

fail-fast iterator
0
Posted

What is a fail-fast iterator?

0

Location: http://www.jguru.com/faq/view.jsp?EID=221988 Created: Oct 3, 2000 Modified: 2005-08-17 01:37:03.148 Author: Avi Kak (http://www.jguru.com/guru/viewbio.jsp?EID=26410) An iterator is considered fail-fast if it throws a ConcurrentModificationException under either of the following two conditions: • In multithreaded processing: if one thread is trying to modify a Collection while another thread is iterating over it. • In single-threaded or in multithreaded processing: if after the creation of the Iterator, the container is modified at any time by any method other than the Iterator’s own remove or add methods. Note in particular what is implied by the second condition: After we create a container’s iterator, during a loop that iterates over the container we must only use the remove (and when applicable add) methods defined for the iterator and that we must NOT use the same methods defined for the container itself. To illustrate this point, suppose we declare and initialize a List

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123