This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Exception in thread "Timer-0" java.util.ConcurrentModificationException  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am running a swing application. And i am getting this error several times, even after changing the code. I am using a java.util.timer, to display moving circles in a panel and do certain functions depending on its position.
The timer starts and everything goes perfectly fine for about 5-10minutes and then, this error is shown:
How may I fix this?

Exception in thread "Timer-0" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at simulation.SceneDetails.setManetListForDesert(SceneDetails.java:325)
at simulation.nodePanel$1.run(SimualtionFrame.java:227)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Thanks.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the documentation for that exception?
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rose Jac wrote:I am running a swing application. And i am getting this error several times, even after changing the code. I am using a java.util.timer, to display moving circles in a panel and do certain functions depending on its position.
The timer starts and everything goes perfectly fine for about 5-10minutes and then, this error is shown:
How may I fix this?

Exception in thread "Timer-0" java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at simulation.SceneDetails.setManetListForDesert(SceneDetails.java:325)
at simulation.nodePanel$1.run(SimualtionFrame.java:227)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Thanks.



Hi Rose,

There is a possibilty of one thread modfying the list when other thread is iterating through the list...best way to fix this issue is put your Arraylist under sysnchronized block and have a check on each thread which access this list.
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!