Class ThreadService
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.ThreadService
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Get the caller of a given method, this should only be used for debugging purposes and is not performant.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.void
newThread
(JavaPlugin plugin, String name, Runnable runnable) Invoke a new thread from the cached thread pool with the given name.
-
Constructor Details
-
ThreadService
-
-
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 usingBukkitScheduler.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
- TheJavaPlugin
that is creating this threadname
- The name of this thread, this will be prefixed with the plugin's namerunnable
- TheRunnable
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 usingBukkitScheduler.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
- TheJavaPlugin
that is creating this threadname
- The name of this thread, this will be prefixed with the plugin's namerunnable
- TheRunnable
to execute
-
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.
-