public class Runners extends Object
| Modifier and Type | Method and Description |
|---|---|
static Runner |
dynamicPoolRunner(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit keepAliveUnit)
Returns a runner employing a dynamic pool of threads.
The number of threads may increase when needed from the core to the maximum pool size. |
static Runner |
poolRunner()
Returns a runner employing an optimum number of threads.
|
static Runner |
poolRunner(int poolSize)
Returns a runner employing the specified number of threads.
|
static PriorityRunner |
priorityRunner(Runner wrapped)
Returns a runner providing ordering of executions based on priority.
|
static Runner |
scheduledRunner(ScheduledExecutorService service)
Returns a runner employing the specified executor service.
|
static Runner |
sharedRunner()
Returns the shared instance of a thread pool asynchronous runner.
|
static Runner |
syncRunner()
Returns the shared instance of a synchronous runner.
|
static Runner |
throttlingRunner(Runner wrapped,
int maxExecutions)
Returns a runner throttling the number of running executions so to keep it under the
specified limit.
|
@NotNull public static Runner dynamicPoolRunner(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull TimeUnit keepAliveUnit)
corePoolSize - the number of threads to keep in the pool, even if they are idle.maximumPoolSize - the maximum number of threads to allow in the pool.keepAliveTime - when the number of threads is greater than the core one, this is the
maximum time that excess idle threads will wait for new tasks before
terminating.keepAliveUnit - the time unit for the keep alive time.@NotNull public static Runner poolRunner()
@NotNull public static Runner poolRunner(int poolSize)
poolSize - the thread pool size.IllegalArgumentException - if the pool size is less than 1.@NotNull public static PriorityRunner priorityRunner(@NotNull Runner wrapped)
wrapped - the wrapped runner instance.@NotNull public static Runner scheduledRunner(@NotNull ScheduledExecutorService service)
service - the executor service.@NotNull public static Runner sharedRunner()
@NotNull public static Runner syncRunner()
@NotNull public static Runner throttlingRunner(@NotNull Runner wrapped, int maxExecutions)
wrapped - the wrapped instance.maxExecutions - the maximum number of running executions.IllegalArgumentException - if the specified max number is less than 1.