java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.ThreadService

public final class ThreadService extends Object
  • Constructor Details

    • ThreadService

      public ThreadService(JavaPlugin plugin)
  • Method Details

    • newThread

      @ParametersAreNonnullByDefault public void newThread(JavaPlugin plugin, String name, Runnable runnable)
      Invoke a new thread from the cached thread pool with the given name. This is a much better alternative to using BukkitScheduler.runTaskAsynchronously(org.bukkit.plugin.Plugin, Runnable) as this will show not only the plugin but a useful name. By default, Bukkit will use "Craft Scheduler Thread - <x> - <plugin>" which is nice to show the plugin but it's impossible to track exactly what thread that is.
      Parameters:
      plugin - The JavaPlugin that is creating this thread
      name - The name of this thread, this will be prefixed with the plugin's name
      runnable - The Runnable to execute
    • newScheduledThread

      @ParametersAreNonnullByDefault public void newScheduledThread(JavaPlugin plugin, String name, Runnable runnable, long delay, long period, TimeUnit unit)
      Invoke a new scheduled thread from the cached thread pool with the given name. This is a much better alternative to using BukkitScheduler.runTaskTimerAsynchronously(org.bukkit.plugin.Plugin, Runnable, long, long) as this will show not only the plugin but a useful name. By default, Bukkit will use "Craft Scheduler Thread - <x> - <plugin>" which is nice to show the plugin but it's impossible to track exactly what thread that is.
      Parameters:
      plugin - The JavaPlugin that is creating this thread
      name - The name of this thread, this will be prefixed with the plugin's name
      runnable - The Runnable to execute
    • getCaller

      public static String getCaller()
      Get the caller of a given method, this should only be used for debugging purposes and is not performant.
      Returns:
      The caller of the method that called this method.