[SOLVED] Thread Problems

Discussion in 'Plugin Development' started by AussieBacom, Apr 2, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    AussieBacom

    I'm having a problem with my plugin. I receive "Thread-#" problems and sometimes under heavy stress the server will crash.

    Some other problems I'm having are that I get repeated potion splashes a while after.

    Error Code:
    Code:
    16:34:02 [SEVERE] Exception in thread "Thread-829"
    16:34:02 [SEVERE] java.util.ConcurrentModificationException
    16:34:02 [SEVERE]      at java.util.ArrayList$Itr.checkForComodification(Unknow
    n Source)
    16:34:02 [SEVERE]      at java.util.ArrayList$Itr.next(Unknown Source)
    16:34:02 [SEVERE]      at org.bukkit.craftbukkit.CraftWorld.getPlayers(CraftWor
    ld.java:637)
    16:34:02 [SEVERE]      at org.bukkit.craftbukkit.CraftWorld.playEffect(CraftWor
    ld.java:780)
    16:34:02 [SEVERE]      at org.bukkit.craftbukkit.CraftWorld.playEffect(CraftWor
    ld.java:756)
    16:34:02 [SEVERE]      at com.haydntrigg.FightingForFun.FFFListener$1.run(FFFLi
    stener.java:257)
    >
    Code From about line 257:
    Code:
            public void potionsplash(final Location location, final int x,
                    final int y, final int z, final int id) {
                final Effect POTION_BREAK = Effect.POTION_BREAK;
             
                Thread t = new Thread(){
                    public void run() {
                      while(true) {
                          int totalsplashes = 10;
                          if(totalsplashes >= 0) {
                                location.getWorld().playEffect(location.add(x,y,z),POTION_BREAK,id);//257
                          }
                      try {
                        Thread.sleep(60 * 1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                      }
                    }
                    };
                    t.start();
                     
            }
     
  2. Offline

    CorrieKay

    are you starting that thread from within that thread? check your bracket locations. looks like youre recursively creating threads from within threads... or something. Not sure :p

    also, try using a TimerTask, and running through the scheduler. The bukkit scheduler handles all threads, so you dont have to!
     
    AussieBacom likes this.
  3. Offline

    AussieBacom

    I fixed it, I didn't know about the bukkit scheduler. Cheers.
     
    #define and CorrieKay like this.
Thread Status:
Not open for further replies.

Share This Page