Using Threads

Discussion in 'Plugin Development' started by SgtStud, Mar 11, 2012.

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

    SgtStud

    Hey guys. Im a moderate Java developer and a newish bukkit developer. Is it possible to add Threads to the server without a client mod? It seems like it should be, but Im not sure.

    The threads do not actually do anything important per say, but they call different methods from the main mc thread.

    Thanks!
     
  2. Code:
    Bukkit.getScheduler();
    // This class is related to timers within the minecraft ticks.
    // for example
     
    Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, runnable, delay, interval);
    // this will start a repeating timer which will start after --delay-- ticks,
    // and repeat it every --interval-- ticks.
    // if you didn't know, 20 minecraft ticks is 1 real life second.
    
    have fun!
     
  3. Offline

    SgtStud

    Beautiful! Thanks!

    Last thing, does this mean there are no extra threads?
     
  4. Offline

    deltahat

    Scheduler.scheduleAsyncRepeqatingTask will cause your task to be executed in a thread separate from the main game thread. Be careful that you don't modify the game from a separate thread. The results are not defined and you can corrupt the server.
     
Thread Status:
Not open for further replies.

Share This Page