Class ThreadRenamingSubmitterScheduler
- java.lang.Object
-
- org.threadly.concurrent.AbstractSubmitterExecutor
-
- org.threadly.concurrent.AbstractSubmitterScheduler
-
- org.threadly.concurrent.wrapper.traceability.ThreadRenamingSubmitterScheduler
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,SubmitterExecutor
,SubmitterScheduler
- Direct Known Subclasses:
ThreadRenamingSchedulerService
public class ThreadRenamingSubmitterScheduler extends AbstractSubmitterScheduler
Class which wraps aSubmitterScheduler
and wraps all supplied tasks in aThreadRenamingRunnable
. This allows you to make a pool where all tasks submitted inside it have the threads named in an identifiable way.- Since:
- 4.8.0 (since 4.3.0 as org.threadly.concurrent.ThreadRenamingSubmitterSchedulerWrapper)
-
-
Constructor Summary
Constructors Constructor Description ThreadRenamingSubmitterScheduler(SubmitterScheduler scheduler, java.lang.String threadName, boolean replace)
Constructs a newThreadRenamingSubmitterScheduler
, wrapping a suppliedSubmitterScheduler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.threadly.concurrent.AbstractSubmitterScheduler
schedule, submitScheduled, submitScheduled
-
Methods inherited from class org.threadly.concurrent.AbstractSubmitterExecutor
execute, submit, submit
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.threadly.concurrent.SubmitterExecutor
submit, submit, submit
-
Methods inherited from interface org.threadly.concurrent.SubmitterScheduler
submitScheduled
-
-
-
-
Constructor Detail
-
ThreadRenamingSubmitterScheduler
public ThreadRenamingSubmitterScheduler(SubmitterScheduler scheduler, java.lang.String threadName, boolean replace)
Constructs a newThreadRenamingSubmitterScheduler
, wrapping a suppliedSubmitterScheduler
. Ifreplace
isfalse
the thread will be named such thatthreadName[originalThreadName]
.- Parameters:
scheduler
- SubmitterScheduler to wrap and send executions tothreadName
- Thread name prefix, or replaced namereplace
- Iftrue
the original name wont be included in the thread name
-
-
Method Detail
-
scheduleWithFixedDelay
public void scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long recurringDelay)
Description copied from interface:SubmitterScheduler
Schedule a fixed delay recurring task to run. The recurring delay time will be from the point where execution has finished. So the execution frequency is therecurringDelay + 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).- Parameters:
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runrecurringDelay
- delay in milliseconds for running task after last finish
-
scheduleAtFixedRate
public void scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period)
Description copied from interface:SubmitterScheduler
Schedule a fixed rate recurring task to run. The recurring delay will be the same, regardless of how long task execution takes. A given runnable will not run concurrently (unless it is submitted to the scheduler multiple times). Instead of execution takes longer than the period, the next run will occur immediately (given thread availability in the pool).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).- Parameters:
task
- runnable to be executedinitialDelay
- delay in milliseconds until first runperiod
- amount of time in milliseconds between the start of recurring executions
-
-