Better Repeating Task

Discussion in 'Plugin Development' started by sohardhun15, Jan 30, 2016.

Thread Status:
Not open for further replies.
  1. Hi! My question is what another way is there, to create a Repeating Task what uses less resources?
    Code:
            runnable = Main.plugin.getServer().getScheduler()
                    .scheduleAsyncRepeatingTask(Main.plugin, new Runnable() {
    
                        @Override
                        public void run() {
                            Bukkit.broadcastMessage("test");
                        }
                    }, 600, 20 * 60 * LoopTime);
     
  2. Offline

    I Al Istannen

    @sohardhun15 I don't think that there is a way to have a less resource intensive task. It all depends on the logic inside. Bukkit just calls it, not that much to optimize there for you. And, honestly, I wouldn't use an async task. Bukkit isn't thread safe and many things can break.
     
  3. Then what should i use ?:D
     
  4. Offline

    I Al Istannen

  5. Offline

    Zombie_Striker

    @sohardhun15
    • The tasks themselves do not take up that much memory, its what you do in them that takes up memory.
    • Please do not use Async threads unless you know how to manage one.
    • The recommended way of creating runnables is through BukkitRunnables.
     
Thread Status:
Not open for further replies.

Share This Page