Class Multithreading

java.lang.Object
org.polyfrost.oneconfig.utils.v1.Multithreading

public final class Multithreading extends Object
Allows for easy multithreading.

Modified from Seraph by Scherso under LGPL-2.1 https://github.com/Scherso/Seraph/blob/master/LICENSE

  • Method Details

    • submit

      public static void submit(Runnable... runnables)
      Runs the provided runnables asynchronously.
      Parameters:
      runnables - The runnables to run.
      See Also:
    • submit

      public static Future<?> submit(Runnable runnable)
      Submits the Runnable to the executor, making it run asynchronously.
      Parameters:
      runnable - The runnable to run.
      Returns:
      The future representing the submitted runnable.
      See Also:
    • schedule

      public static void schedule(Runnable runnable, long delay, TimeUnit timeUnit)
      Schedules the runnable to run asynchronously after the specified delay.
      Parameters:
      runnable - The runnable to run.
      delay - The delay before the runnable is run.
      timeUnit - The TimeUnit of the delay.
      See Also:
    • submitScheduled

      public static ScheduledFuture<?> submitScheduled(Runnable runnable, long delay, TimeUnit timeUnit)
      Submits the Runnable to the executor after a delay, making it run asynchronously.
      Parameters:
      runnable - The runnable to run.
      delay - The delay before the runnable is run.
      timeUnit - The TimeUnit of the delay.
      Returns:
      The future representing the submitted runnable.
      See Also:
    • getExecutor

      public static ExecutorService getExecutor()
    • getScheduledExecutor

      public static ScheduledExecutorService getScheduledExecutor()