public abstract class SchedulingStrategy extends Object
Scheduler
.
The strategy is scheduling tasks in schedule(Runnable)
and awaiting them
completed in finished()
. Both methods should be used in one thread.Constructor and Description |
---|
SchedulingStrategy() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
canSchedule() |
protected abstract boolean |
finished()
Waiting for scheduled tasks to finish.
|
protected abstract boolean |
hasSharedThreadPool() |
protected abstract void |
schedule(Runnable task)
Schedules tasks if
canSchedule() . |
protected void |
setDefaultShutdownHandler(Scheduler.ShutdownHandler handler) |
protected abstract boolean |
stop()
Stops scheduling new tasks (e.g.
|
protected boolean |
stopNow()
Stops scheduling new tasks and interrupts running tasks
(e.g.
|
protected abstract void schedule(Runnable task)
canSchedule()
.task
- runnable to schedule in a thread pool or invokeRejectedExecutionException
- if task
cannot be scheduled for executionNullPointerException
- if task is nullRunnerScheduler.schedule(Runnable)
,
Executor.execute(Runnable)
protected abstract boolean finished() throws InterruptedException
InterruptedException
- if interrupted while waiting
for scheduled tasks to finishRunnerScheduler.finished()
protected abstract boolean stop()
ExecutorService.shutdown()
on a private thread pool which cannot be shared with other strategy).ExecutorService.shutdown()
protected boolean stopNow()
ExecutorService.shutdownNow()
on a private thread pool
which cannot be shared with other strategy).
This method calls stop()
by default.
ExecutorService.shutdownNow()
protected void setDefaultShutdownHandler(Scheduler.ShutdownHandler handler)
protected abstract boolean hasSharedThreadPool()
protected abstract boolean canSchedule()
Copyright © 2004–2013 The Apache Software Foundation. All rights reserved.