Collections have specific concurrency issues. I'm a .net developer, but I can describe the issues in, fairly general terms I think.
Internally the collection could be implemented in a number of different ways. Let's assume it's just a linked list.
The collection can support a number of operations. Add and delete, delete[index] and insert. It also allows you to iterate over the collection.
So you have concurrent access. Here are some situations to consider.
You are iterating over the entire collection. You are doing something like (pseudo code)
for count = 1 to collection.count
do something
next
For the sake of the following, count currently = 5 and collection.count = 10.
While doing this you do any of the following. Run each scenario individually:
1) Add an item to the collection.
This will probably work as long as the behaviour is to insert the item at the end.
2) Insert an item at position 3
Not too bad, count goes up one, the new item won't be included in our iteration though.
3) Delete an item at position 3
Ok, now we have issues. Count is now 9 (remember do each scenario on its own, 1) and 2) haven't happened in this case). our current position is still 5, but because 3 was removed, the list has moved left, we are now going to skip an item because item 6 is now item 5, and we're already reading 5.
But it gets worse!!! Imagine your stuff that you are doing with item 5 is reading members of the object at position 5 based on its index.
thread 1 --> collection[5].element1 = 10
thread 2 --> delete item 3
thread 1 --> collection[5].element2 = 10
we've actually now set two elements on different items.
It get's worse still in the next one.
4) delete item 5 while currently on item 5.
Yep, you remove the item, perhaps call its "Dispose" method as you remove it but you're still treating it as an active member of the collection on another thread.
That's simple cases. Hope it gives you some ideas.