Solved runTaskLater() - Question

Discussion in 'Plugin Development' started by Oneric-1st, May 17, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I just want to know if a Task started with the
    Code:
    Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){...},  DELAY)
    method will cancel itself.

    Thank you !

    ~Oneric
     
  2. Offline

    ZachBora

    What do you mean if it will cancel itself?
    You can cancel a task if you save it's task Id. But to cancel a task from itself, just make it return;.
     
  3. With cancel I mean, that it's not longer kind of stored by the Scheduler even after the Task has run.
    Like if I create a new of this tasks every time the last is finished, it won't spam the RAM with unnecessary Runnables ( what I do not do, just an example ).
     
  4. All objects will sit in the RAM until they don't have any variables pointing to them, after that point the garbage collector will remove them when it runs and thus freeing up RAM... for more info google about Java's garbage collector.
     
  5. I already know the garbage Collector, but maybe I understood something wrong or explained it bad.

    The point is, if the Scheduler / Bukkit (or whatever) is keeping the Runnable in a kind of ArrayList, it will not be removed from Garbage Collector, or I'm wrong ?
     
  6. Oneric-1st
    Since Bukkit is not built by amatures, I belive that once the task finished then Bukkit will remove any reference to the object, allowing it to be collected.
     
  7. Digi

    Ok,
    thank you !
     
Thread Status:
Not open for further replies.

Share This Page