• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to debug Concurrent Modification Exception?  RSS feed

 
mangesh lele
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting Concurrent Modification Exception while iterating an arraylist, when the next method is called. I want to know how I can debug this error since my program is seemingly running in a single thread. The docs given are not really helpful in that regard.
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start by identifying all program lines where the ArrayList is modified.
Bill
 
sopal Pal
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
If you are using a for loop using an Iterator and also at the same time, removing any items within the for loop on which the Iterator depends you will get this type of an error.
Look into the Vector class documentation.
If u iterate through the vector elements using an Iterator and in the same loop modify any of the elements you will get the same error.
Since, ArrayList is almost exactly like a Vector but for the Synchronized implementation, you are probbaly running into this error.
I hope this helps
Sumit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!