Package de.presti.ree6.utils.others
Class ThreadUtil
java.lang.Object
de.presti.ree6.utils.others.ThreadUtil
This util class is used to create ASyncThreads with consumers in a Thread-pool
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Future<?>
createThread
(Consumer<Void> success) Creates a Thread with a Consumer.static Future<?>
createThread
(Consumer<Void> success, Duration duration, boolean loop, boolean pre) Creates a Thread with a Consumer.static Future<?>
createThread
(Consumer<Void> success, Consumer<Throwable> failure) Creates a Thread with a Consumer.static Future<?>
createThread
(Consumer<Void> success, Consumer<Throwable> failure, Duration duration, boolean loop, boolean pre) Creates a Thread with a Consumer.
-
Constructor Details
-
ThreadUtil
public ThreadUtil()
-
-
Method Details
-
createThread
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
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.
-