ConcurrentModificationException : This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible.<
I don't think 'concurrent' means thread-related in this case, or at least it doesn't necessarily mean that. ConcurrentModificationException
s usually arise from modifying a collection while in the process of iterating over it.
List list = new ArrayList();
for(String s : list)
{
//modifying list results in ConcurrentModificationException
list.add("don't do this");
}
Note that the Iterator<>
class has a few methods that can circumvent this:
for(Iterator it = list.iterator(); it.hasNext())
{
//no ConcurrentModificationException
it.remove();
}