Thread: EventManager {ASAP}

Results 1 to 6 of 6
  1. #1 EventManager {ASAP} 
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    [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!
    Reply With Quote  
     

  2. #2  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Bump
    Reply With Quote  
     

  3. #3  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    you're trying to remove an item from a list you're iterating over
    e.g
    Code:
    for (Player : players) {
      if (player.name == 'harlan')
           players.remove(player); /// currentt exception thrown here!!
    }
    post code if u need more help
    Reply With Quote  
     

  4. #4  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Quote Originally Posted by Harlan View Post
    you're trying to remove an item from a list you're iterating over
    e.g
    Code:
    for (Player : players) {
      if (player.name == 'harlan')
           players.remove(player); /// currentt exception thrown here!!
    }
    post code if u need more help
    Do you have skype?
    I don't feel like sharing my codes with anyone.. yea.. exacly..
    Reply With Quote  
     

  5. #5  
    Banned EventManager {ASAP} Market Banned


    Join Date
    Jan 2011
    Age
    26
    Posts
    3,112
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    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


    Quote Originally Posted by Harlan View Post
    you're trying to remove an item from a list you're iterating over
    e.g
    Code:
    for (Player : players) {
      if (player.name == 'harlan')
           players.remove(player); /// currentt exception thrown here!!
    }
    post code if u need more help
    it will throw that exception if an element is added as well (which is what is happening in this case)
    Reply With Quote  
     

  6. #6  
    Donator

    Arithium's Avatar
    Join Date
    May 2010
    Age
    31
    Posts
    4,721
    Thanks given
    199
    Thanks received
    1,256
    Rep Power
    1114
    Quote Originally Posted by lare96 View Post
    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)
    This has nothing to do with his EventManager class. Hes probably removing an object from a list improperly.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 366
    Last Post: 08-30-2011, 10:21 PM
  2. Eventmanager??
    By walid in forum Help
    Replies: 15
    Last Post: 01-25-2009, 06:35 PM
  3. Explaining Graham's EventManager
    By Shelton in forum Tutorials
    Replies: 0
    Last Post: 10-06-2008, 02:06 PM
  4. Making Events, with Graham's EventManager
    By OG KingFox in forum Tutorials
    Replies: 10
    Last Post: 09-19-2008, 05:31 PM
  5. i need client bg asap!
    By Mason in forum Graphics
    Replies: 4
    Last Post: 04-19-2008, 10:26 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •