Class ScheduledExecutorServiceWrapper
- java.lang.Object
-
- org.threadly.concurrent.AbstractSubmitterExecutor
-
- org.threadly.concurrent.AbstractSubmitterScheduler
-
- org.threadly.concurrent.wrapper.compatibility.ScheduledExecutorServiceWrapper
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,SubmitterExecutor
,SubmitterScheduler
public class ScheduledExecutorServiceWrapper extends AbstractSubmitterScheduler
This is a wrapper for theScheduledThreadPoolExecutor
to use that implementation with theSubmitterScheduler
.- Since:
- 4.6.0 (since 1.0.0 at org.threadly.concurrent)
-
-
Constructor Summary
Constructors Constructor Description ScheduledExecutorServiceWrapper(java.util.concurrent.ScheduledExecutorService scheduler)
Constructs a new wrapper with the provided scheduler implementation.
-
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
-
-
-
-
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
-
-