exception - java.util.ConcurrentModificationException in javafx timeline -
this question has answer here:
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
Post a Comment