Class ThreadUtil

java.lang.Object
de.presti.ree6.utils.others.ThreadUtil

public class ThreadUtil extends Object
This util class is used to create ASyncThreads with consumers in a Thread-pool
  • Constructor Details

    • ThreadUtil

      public ThreadUtil()
  • Method Details

    • createThread

      public static Future<?> createThread(Consumer<Void> success)
      Creates a Thread with a Consumer.
      Parameters:
      success - the Consumer, that will be executed, when the Thread is finished.
      Returns:
      the Future of the Thread.
    • createThread

      public static Future<?> createThread(Consumer<Void> success, Consumer<Throwable> failure)
      Creates a Thread with a Consumer.
      Parameters:
      success - the Consumer, that will be executed, when the Thread is finished.
      failure - the Consumer, that will be executed, when the Thread failed.
      Returns:
      the Future of the Thread.
    • createThread

      public static Future<?> createThread(Consumer<Void> success, Duration duration, boolean loop, boolean pre)
      Creates a Thread with a Consumer.
      Parameters:
      success - the Consumer, that will be executed, when the Thread is finished.
      duration - the delay duration of the Thread.
      loop - if the Thread should be looped.
      pre - the Consumer, that will be executed, before the Thread is going into the sleep state.
      Returns:
      the Future of the Thread.
    • createThread

      public static Future<?> createThread(Consumer<Void> success, Consumer<Throwable> failure, Duration duration, boolean loop, boolean pre)
      Creates a Thread with a Consumer.
      Parameters:
      success - the Consumer, that will be executed, when the Thread is finished.
      failure - the Consumer, that will be executed, when the Thread failed.
      duration - the delay duration of the Thread.
      loop - if the Thread should be looped.
      pre - the Consumer, that will be executed, before the Thread is going into the sleep state.
      Returns:
      the Future of the Thread.