Steve Luke wrote:Hi Cunces,
Next time you post code, could you put your code in [code][/code] tags? It makes it a lot more readable. There is a button at the top of the message form you can use for adding the tags for you. You can also go back and edit your post to add them in.
To your question, the cocnurrent modification exception can occur if another thread modifies the list while this thread iterates over it. In your case, you have a different part of code which adds to the list which may happen when the list is being iterated over, so the problem can occur.
To get around this you should use a thread-safe collection which would prevent the ConcurrentModificationException. Take a look at the collections available in the java.util.concurrent package. ConcurrentLinkedQueue might work alright for you, or perhaps CopyOnWriteArrayList.