Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Concurrent Modification Exception -- weird fix

807591Apr 2 2008 — edited Apr 3 2008
while(childItr.hasNext()){
Peer child = childItr.next();

child.myClientSession.myPeers.add(contactMsg.source);
}

The code above gave me a Concurrent Modification Exception at line >>Peer child = childItr.next();
Then, I simply added the below line in between the two lines in the while
child = child;

The bug is fixed.. But it intrigues me..
What would have happened given that myPeers is a HashSet and this code runs within a method of the same 'Peer' class

thanks
vinoth
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2008
Added on Apr 2 2008
15 comments
499 views