abstract class AbstractThreadPoolStrategy extends SchedulingStrategy
SchedulingStrategy,
SharedThreadPoolStrategy,
NonSharedThreadPoolStrategy| Modifier and Type | Field and Description |
|---|---|
private java.util.Collection<java.util.concurrent.Future<?>> |
futureResults |
private boolean |
isDestroyed |
private java.util.concurrent.ExecutorService |
threadPool |
| Constructor and Description |
|---|
AbstractThreadPoolStrategy(ConsoleStream logger,
java.util.concurrent.ExecutorService threadPool) |
AbstractThreadPoolStrategy(ConsoleStream logger,
java.util.concurrent.ExecutorService threadPool,
java.util.Collection<java.util.concurrent.Future<?>> futureResults) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
destroy()
Calling
ThreadPoolExecutor.shutdown()
and ThreadPoolExecutor.awaitTermination(long, java.util.concurrent.TimeUnit). |
protected java.util.Collection<java.util.concurrent.Future<?>> |
getFutureResults() |
protected java.util.concurrent.ExecutorService |
getThreadPool() |
void |
schedule(java.lang.Runnable task)
Schedules tasks if
SchedulingStrategy.canSchedule(). |
protected void |
setDefaultShutdownHandler(Scheduler.ShutdownHandler handler) |
protected boolean |
stop()
Stops scheduling new tasks (e.g.
|
protected boolean |
stopNow()
Stops scheduling new tasks and
interrupts running tasks
(e.g. |
canSchedule, disable, finished, hasSharedThreadPool, logQuietlyprivate final java.util.concurrent.ExecutorService threadPool
private final java.util.Collection<java.util.concurrent.Future<?>> futureResults
private volatile boolean isDestroyed
AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool)
AbstractThreadPoolStrategy(ConsoleStream logger, java.util.concurrent.ExecutorService threadPool, java.util.Collection<java.util.concurrent.Future<?>> futureResults)
protected final java.util.concurrent.ExecutorService getThreadPool()
protected final java.util.Collection<java.util.concurrent.Future<?>> getFutureResults()
public void schedule(java.lang.Runnable task)
SchedulingStrategySchedulingStrategy.canSchedule().schedule in class SchedulingStrategytask - runnable to schedule in a thread pool or invokeRunnerScheduler.schedule(Runnable),
Executor.execute(Runnable)protected boolean stop()
SchedulingStrategyExecutorService.shutdown()
on a private thread pool which cannot be shared with other strategy).stop in class SchedulingStrategytrue if successfully stopped the scheduler, else
false if already stopped (a shared thread
pool was shutdown externally).ExecutorService.shutdown()protected boolean stopNow()
SchedulingStrategyinterrupts running tasks
(e.g. by ExecutorService.shutdownNow() on a private thread pool
which cannot be shared with other strategy).
SchedulingStrategy.stop() by default.stopNow in class SchedulingStrategytrue if successfully stopped the scheduler, else
false if already stopped (a shared thread
pool was shutdown externally).ExecutorService.shutdownNow()protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler)
setDefaultShutdownHandler in class SchedulingStrategyScheduler.ShutdownHandlerpublic boolean destroy()
DestroyableThreadPoolExecutor.shutdown()
and ThreadPoolExecutor.awaitTermination(long, java.util.concurrent.TimeUnit).true if not interrupted in current thread