public class ThreadRenamingSubmitterScheduler extends AbstractSubmitterScheduler
SubmitterScheduler
and wraps all supplied tasks in a
ThreadRenamingRunnable
. This allows you to make a pool where all tasks submitted
inside it have the threads named in an identifiable way.Constructor and Description |
---|
ThreadRenamingSubmitterScheduler(SubmitterScheduler scheduler,
java.lang.String threadName,
boolean replace)
Constructs a new
ThreadRenamingSubmitterScheduler , wrapping a supplied
SubmitterScheduler . |
Modifier and Type | Method and Description |
---|---|
void |
scheduleAtFixedRate(java.lang.Runnable task,
long initialDelay,
long period)
Schedule a fixed rate recurring task to run.
|
void |
scheduleWithFixedDelay(java.lang.Runnable task,
long initialDelay,
long recurringDelay)
Schedule a fixed delay recurring task to run.
|
schedule, submitScheduled, submitScheduled
execute, submit, submit
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
submitScheduled
submit, submit, submit
public ThreadRenamingSubmitterScheduler(SubmitterScheduler scheduler, java.lang.String threadName, boolean replace)
ThreadRenamingSubmitterScheduler
, wrapping a supplied
SubmitterScheduler
. If replace
is false
the thread will be named such
that threadName[originalThreadName]
.scheduler
- SubmitterScheduler to wrap and send executions tothreadName
- Thread name prefix, or replaced namereplace
- If true
the original name wont be included in the thread namepublic void scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long recurringDelay)
SubmitterScheduler
recurringDelay + runtime
for the provided task.
Unlike ScheduledExecutorService
if the task throws an exception,
subsequent executions are NOT suppressed or prevented. So if the task throws an exception on
every run, the task will continue to be executed at the provided recurring delay (possibly
throwing an exception on each execution).
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runrecurringDelay
- delay in milliseconds for running task after last finishpublic void scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period)
SubmitterScheduler
Unlike ScheduledExecutorService
if the task throws an exception,
subsequent executions are NOT suppressed or prevented. So if the task throws an exception on
every run, the task will continue to be executed at the provided recurring delay (possibly
throwing an exception on each execution).
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runperiod
- amount of time in milliseconds between the start of recurring executions