This content has been marked as final. Show 3 replies
You can't remove items from a collection like that while in the middle of iterating over the collection. You'll need to approach the problem in a different way. One way is to manually get the Iterator and use it in a traditional loop, and invoke the Iterator's delete() (or remove(), whatever it is, look it up in the java documentation).
alex.p wrote:That can also do it, but it's not the only way. CCME occurs when a collection being iterated is structurally modified other than by the Iterator. That includes some other thread modifying it (because that other thread will presumably not be accessing this iterator) as well as the current thread modifying the list directly rather than with, e.g., iterator.remove().
Thanks very much, I had it in my head that it was to do with another thread interacting with the same arraylist.