It seems you are faced with a race condition. Multiple threads access the same collection. Use a realistic list implementation.
In addition, you should not modify the collection (add / remove) while iterating on it using Iterator.
EDIT
ConcurrentModificationExeption sounds like a taskCollection gets access and is changed by several threads at the same time (we cannot say that the part of the code that you provide if your program is single or multi-threaded). If you share a taskCollection between multiple threads, use a list implementation with a thread.
But the error here is actually obvious due to the fact that you add an item to the collection between the moment you get an iterator on it, and as soon as you use this iterator. To fix this copy new items in the temporary list and add them all at once at the end of the iteration.
Yanflea
source share