Class ThreadUtils
java.lang.Object
io.github.thebusybiscuit.slimefun4.utils.ThreadUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexecuteSync(Runnable runnable) Executes a task synchronously on the main thread.static voidexecuteSyncSched(Runnable runnable) Executes a task synchronously on the main thread with scheduling.static FutureTask<Void> getFutureTask(Runnable runnable) Creates a FutureTask from a Runnable.static <T> FutureTask<T> getFutureTask(Runnable runnable, T val) Creates a FutureTask from a Runnable with a specific result value.static <T> FutureTask<T> getFutureTask(Callable<T> callable) Creates a FutureTask from a Callable.static Executorstatic Executor
-
Constructor Details
-
ThreadUtils
public ThreadUtils()
-
-
Method Details
-
getMainThreadExecutor
-
getMainDelayedExecutor
-
executeSync
Executes a task synchronously on the main thread. If the current thread is already the main thread, the task runs immediately. Otherwise, the task is scheduled to run on the main thread.- Parameters:
runnable- The task to execute synchronously
-
executeSyncSched
Executes a task synchronously on the main thread with scheduling. If the current thread is already the main thread, the task is scheduled for later execution. Otherwise, the task is scheduled to run on the main thread.- Parameters:
runnable- The task to execute synchronously
-
getFutureTask
Creates a FutureTask from a Callable.- Type Parameters:
T- The type of the result- Parameters:
callable- The callable to wrap- Returns:
- A FutureTask wrapping the callable
-
getFutureTask
Creates a FutureTask from a Runnable. If the input is already a FutureTask, it is cast and returned. Otherwise, a new FutureTask is created with the Runnable and null result.- Parameters:
runnable- The runnable to wrap- Returns:
- A FutureTask wrapping the runnable
-
getFutureTask
Creates a FutureTask from a Runnable with a specific result value.- Type Parameters:
T- The type of the result- Parameters:
runnable- The runnable to executeval- The result value to return- Returns:
- A FutureTask that executes the runnable and returns the specified value
-