This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ConcurrentModificationException why here ?

 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a ConcurrentModificationException, but why here i create a new list

List<String> subListKundeNumre = kundeNumre.subList(0, 999);

And remove elements from the old list:

kundeNumre.subList(0,999).clear();

There is not two threads at the same time .... I can try to do in a other way, but i have to know, why i got this exception, any good ideas ?




// Frank :-)

 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need multiple threads to get that exception. All you need is for the list to be structurally modified other than through the active iterator. It states this right in the docs for the exception.



 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic