You are right there. And I guess the best way to rid this exception then is
to have the code part in synchronized block, i.e., synchronizing on the list
object itself + get the iterator + invoke either "add" or "remove" inside
the block. This will hurt the performance a bit BUT will preserve the
integrity of the content of the list.

On Wed, Feb 27, 2008 at 9:50 AM, Dave Newton <[EMAIL PROTECTED]> wrote:

> --- Eduardo Dela Rosa <[EMAIL PROTECTED]> wrote:
> > Also, you must be removing or updating object directly inside your list
> > object which is why you're getting this error. Try to get a reference to
> > Iterator from your ArrayList object and invoke "remove" or "add" methods
> > via the Iterator to get away from the ConcurrentModificationException.
>
> Strictly speaking I don't believe that's necessarily true; one can get a
> ConcurrentModificationException depending on how a map object is accessed
> in
> the iterator.
>
> (Not totally relevant since we're talking about lists, but thought I'd
> throw
> that out there.)
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Eduardo Dela Rosa

Reply via email to