Package org.threadly.concurrent
Interface SubmitterScheduler
-
- All Superinterfaces:
java.util.concurrent.Executor
,SubmitterExecutor
- All Known Subinterfaces:
PrioritySchedulerService
,SchedulerService
,StatisticPriorityScheduler
- All Known Implementing Classes:
AbstractPriorityScheduler
,AbstractSubmitterScheduler
,DefaultPriorityWrapper
,NoThreadScheduler
,NoThreadSchedulerStatisticTracker
,PriorityDelegatingScheduler
,PriorityScheduler
,PrioritySchedulerServiceQueueLimitRejector
,PrioritySchedulerStatisticTracker
,PrioritySchedulerTaskInterceptor
,ScheduledExecutorServiceWrapper
,SchedulerExecutorDelegator
,SchedulerServiceLimiter
,SchedulerServiceQueueLimitRejector
,SchedulerServiceTaskInterceptor
,SingleThreadScheduler
,SingleThreadSchedulerStatisticTracker
,SingleThreadSchedulerSubPool
,SubmitterSchedulerLimiter
,SubmitterSchedulerQueueLimitRejector
,SubmitterSchedulerTaskInterceptor
,ThreadRenamingPriorityScheduler
,ThreadRenamingSchedulerService
,ThreadRenamingSubmitterScheduler
public interface SubmitterScheduler extends SubmitterExecutor
A thread pool for scheduling tasks with provided futures. This scheduler submits runnables/callables and returns futures for when they will be completed.- Since:
- 4.3.0 (since 1.0.0 as SubmitterSchedulerInterface_
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
schedule(java.lang.Runnable task, long delayInMs)
Schedule a one time task with a given delay.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.default ListenableFuture<?>
submitScheduled(java.lang.Runnable task, long delayInMs)
Schedule a task with a given delay.<T> ListenableFuture<T>
submitScheduled(java.lang.Runnable task, T result, long delayInMs)
Schedule a task with a given delay.<T> ListenableFuture<T>
submitScheduled(java.util.concurrent.Callable<T> task, long delayInMs)
Schedule aCallable
with a given delay.-
Methods inherited from interface org.threadly.concurrent.SubmitterExecutor
submit, submit, submit
-
-
-
-
Method Detail
-
schedule
void schedule(java.lang.Runnable task, long delayInMs)
Schedule a one time task with a given delay.- Parameters:
task
- runnable to executedelayInMs
- time in milliseconds to wait to execute task
-
scheduleWithFixedDelay
void scheduleWithFixedDelay(java.lang.Runnable task, long initialDelay, long recurringDelay)
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
void scheduleAtFixedRate(java.lang.Runnable task, long initialDelay, long period)
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
-
submitScheduled
default ListenableFuture<?> submitScheduled(java.lang.Runnable task, long delayInMs)
Schedule a task with a given delay. There is a slight increase in load when usingsubmitScheduled(Runnable, long)
overschedule(Runnable, long)
. So this should only be used when the future is necessary.The
Future.get()
method will returnnull
once the runnable has completed.- Parameters:
task
- runnable to executedelayInMs
- time in milliseconds to wait to execute task- Returns:
- a future to know when the task has completed
-
submitScheduled
<T> ListenableFuture<T> submitScheduled(java.lang.Runnable task, T result, long delayInMs)
Schedule a task with a given delay. TheFuture.get()
method will return the provided result once the runnable has completed.- Type Parameters:
T
- type of result returned from the future- Parameters:
task
- runnable to executeresult
- result to be returned from resulting future .get() when runnable completesdelayInMs
- time in milliseconds to wait to execute task- Returns:
- a future to know when the task has completed
-
submitScheduled
<T> ListenableFuture<T> submitScheduled(java.util.concurrent.Callable<T> task, long delayInMs)
Schedule aCallable
with a given delay. This is needed when a result needs to be consumed from the callable.- Type Parameters:
T
- type of result returned from the future- Parameters:
task
- callable to be executeddelayInMs
- time in milliseconds to wait to execute task- Returns:
- a future to know when the task has completed and get the result of the callable
-
-