score:4

Accepted answer

it could be that the collection is being modified at the same time as it is being iterated. if this code is accessed by more than one thread simultaneously, you might need to lock the list for modifications while iterating it.

score:1

locking during the tolist is not sufficient. you must also lock (the same object!) during the modification.


Related Query

More Query from same tag