Bump
|
[10/28/14 12:30 PM]: Exception in thread "Thread-2" [10/28/14 12:30 PM]: java.util.ConcurrentModificationException
[10/28/14 12:30 PM]: at java.util.ArrayList$Itr.checkForComodification(Unk nown Source)
[10/28/14 12:30 PM]: at java.util.ArrayList$Itr.next(Unknown Source)
[10/28/14 12:30 PM]: at server.model.minigames.EventManager.run(EventManag er.java:96)
[10/28/14 12:30 PM]: at java.lang.Thread.run(Unknown Source)
Any clue why this happens?
I basicly handle 2 events which are LobbyTimer and GameTimer.
Once lobbyTimer reachs 0 the LobbyTimer event is stop(); and then GameTimer starts.
Why do I keep getting this error?
Will rep ++ & thank!
you're trying to remove an item from a list you're iterating over
e.g
post code if u need more helpCode:for (Player : players) { if (player.name == 'harlan') players.remove(player); /// currentt exception thrown here!! }
the EventManager doesn't have support for starting new tasks within tasks. you're starting a new event within an existing one, which is why it's throwing that error.
you can add support for scheduling tasks within tasks with the EventManager (don't recommend it) by using a CopyOnWriteArrayList (they're slow and generally used for concurrency, not recommended) or by queuing newly added tasks and polling them into the main task list at the beginning of each cycle (will work fine but the EventManager is really old... just use something newer)
graham's newer cycle-based task system does the queuing already to avoid ConcurrentModificationException's
it will throw that exception if an element is added as well (which is what is happening in this case)
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |