Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It is possible that in a multithreaded program, one thread iterates over a collection while another concurrently modifies the Collectionit. This can result in unspecified behavior. Many implementations throw a ConcurrentModificationException when such a condition is detected.

...

The message is clear, do not rely on ConcurrentModificationException to stop any side effects resulting from modifying an underlying Collection while iterating over it. Notably, the enhanced for loop (for-each idiom) internally uses an Iterator.

...