exception - java.util.ConcurrentModificationException in javafx timeline -


i haven't made thread myself. have 1 timeline runs beginning end of program follows:

timeline timeline = new timeline(         new keyframe(duration.millis(timeline_delay), event -> {             intruderslist.foreach(intruder::action);             towerslist.foreach(tower::action);             otheractiveslist.foreach(active::action);         })); timeline.setcyclecount(timeline.indefinite); timeline.play(); 

and when die method of intruder class called, concurrent modification exception.

first, don't understand how timeline works! create new threads or what? , happen if example have timeline task every 10 seconds , task takes 15 seconds done! , second indeed: how can fixed!?

public void die() {     this.getcell().getcontent().remove(this);     timeline.getinstance().removeintruder(this);     system.out.println("death of intruder at: " + cell); } 

check out docs. exceptions typically happens when list modified while not allowed.

this can occur when 2 different threads trying modify same list concurrently, more means trying modify list while iterating on (which not allowed).


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -