On Oct 24, 2008, at 13:47 , Andrey Razumovsky wrote:

The problem is NOT that some list is accessed by multiple threads. The
problem is that java throws ConcurrentModificationException when you delete an object from the list while iteration over it. Two solutions I know from
my experience are:
1. First do operations, and afterwards delete (done in the code).
2. Iterate through array with simple loop (e.g. for (int i = 0; i <
list.size(); i++) - this helps in your case, because we have only one
modification thread, but still I don't trust this code somewhy and try to
avoid it. Also here we'll need to manually change the index (i-- when
element is deleted).

3. Iterator#remove?

Also note that there is just ONE thread accessing to the list, so all
synchronization is useless and may result in deadlock!

Okay, then you should probably not use Vector that is synchronized all over?

 - Tore.

Reply via email to