Forum Home
Press F1
 
Thread ID: 25982 2002-10-16 13:24:00 Java concurrentModificationException frei007 (2258) Press F1
Post ID Timestamp Content User
89854 2002-10-16 13:24:00 hello,

i have an array list of sets that i am trying to iterate through.
My array list is synchronised and i have two iterators that iterate through the array
and compare one set to another and then i define two iterators on the sets in the array and
compare the elements in each set. The problem is that i get a concurrentModificationException

I have tried two approaches to defining the set and its iterator, the componentListItr1 and
componentListItr2 Iterators are the iterators over the synchronized arraylist, both of which
throw the same Exception:

Appraoch 1:

Set componentSubset1 = (Set)componentListItr1.next();
Set componentSubset2 = (Set)componentListItr2.next();


Approach 2:

Set componentSubset1 = Collections.synchronizedSet(new HashSet());
componentSubset1.addAll((Set)componentListItr1.nex t());

Set componentSubset2 = Collections.synchronizedSet(new HashSet());
componentSubset2.addAll((Set)componentListItr2.nex t());

Thanks,

an expat Kiwi
frei007 (2258)
1