Package org.drasyl.util.scheduler
Class DrasylSchedulerUtil
- java.lang.Object
-
- org.drasyl.util.scheduler.DrasylSchedulerUtil
-
public final class DrasylSchedulerUtil extends Object
It is an intentional behavior that this scheduler ensures that the JVM is not automatically terminated once all sequential program flows have been processed. A corePoolSize of 0 would prevent this behavior, but would also have a negative effect on performance. The ThreadPool would not start to create a new thread to process until the workQueue limit is reached. Assuming that the workQueue limit is never reached, the schedule would never start processing the already submitted tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DrasylSchedulerUtil.DrasylExecutor
-
Field Summary
Fields Modifier and Type Field Description static Duration
SHUTDOWN_TIMEOUT
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DrasylScheduler
getInstanceHeavy()
Use thisDrasylScheduler
for slow and heavy task that does do longer computations.static DrasylScheduler
getInstanceLight()
Use thisDrasylScheduler
for fast and light task that does not do heavy computations.static CompletableFuture<Void>
shutdown()
Shutdown the two schedulers.
-
-
-
Field Detail
-
SHUTDOWN_TIMEOUT
public static final Duration SHUTDOWN_TIMEOUT
-
-
Method Detail
-
getInstanceLight
public static DrasylScheduler getInstanceLight()
Use thisDrasylScheduler
for fast and light task that does not do heavy computations.- Returns:
- a
DrasylScheduler
for fast and light tasks
-
getInstanceHeavy
public static DrasylScheduler getInstanceHeavy()
Use thisDrasylScheduler
for slow and heavy task that does do longer computations.- Returns:
- a
DrasylScheduler
for slow and heavy tasks
-
shutdown
public static CompletableFuture<Void> shutdown()
Shutdown the two schedulers.This operation cannot be undone. After performing this operation, no new task can be submitted!
-
-