Interface BackgroundExecutor
-
public interface BackgroundExecutor
Background executor service for executing of tasks asynchronously.This service can be used to execute tasks in the background.
This service is managed by Ebean and will perform a clean shutdown waiting for background tasks to complete with a default 30 second timeout. Shutdown occurs prior to DataSource shutdown.
This also propagates MDC context from the current thread to the background task if defined.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidexecute(Runnable task)Execute a task in the background.voidexecutePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit)Deprecated.voidexecutePeriodically(Runnable task, long delay, TimeUnit unit)Deprecated.ScheduledFuture<?>schedule(Runnable task, long delay, TimeUnit unit)Schedules a Runnable for one-shot action that becomes enabled after the given delay.<V> ScheduledFuture<V>schedule(Callable<V> task, long delay, TimeUnit unit)Schedules a Callable for one-shot action that becomes enabled after the given delay.ScheduledFuture<?>scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)Execute a task periodically with a given period.ScheduledFuture<?>scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)Execute a task periodically with a given delay.Future<?>submit(Runnable task)Execute a runnable task in the background returning the Future.<T> Future<T>submit(Callable<T> task)Execute a callable task in the background returning the Future.
-
-
-
Method Detail
-
submit
<T> Future<T> submit(Callable<T> task)
Execute a callable task in the background returning the Future.
-
submit
Future<?> submit(Runnable task)
Execute a runnable task in the background returning the Future.
-
execute
void execute(Runnable task)
Execute a task in the background. Effectively the same assubmit(Runnable)but returns void.
-
executePeriodically
@Deprecated void executePeriodically(Runnable task, long delay, TimeUnit unit)
Deprecated.Deprecated - migrate to scheduleWithFixedDelay(). Execute a task periodically with a fixed delay between each execution.For example, execute a runnable every minute.
The delay is the time between executions no matter how long the task took. That is, this method has the same behaviour characteristics as
ScheduledExecutorService.scheduleWithFixedDelay(Runnable, long, long, TimeUnit)
-
executePeriodically
@Deprecated void executePeriodically(Runnable task, long initialDelay, long delay, TimeUnit unit)
Deprecated.Deprecated - migrate to scheduleWithFixedDelay(). Execute a task periodically additionally with an initial delay different from delay.
-
scheduleWithFixedDelay
ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit)
Execute a task periodically with a given delay.- Parameters:
task- the task to executeinitialDelay- the time to delay first executiondelay- the delay between the termination of one execution and the commencement of the nextunit- the time unit of the initialDelay and delay parameters- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
-
scheduleAtFixedRate
ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
Execute a task periodically with a given period.If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
- Parameters:
task- the task to executeinitialDelay- the time to delay first executionperiod- the period between successive executionsunit- the time unit of the initialDelay and period parameters- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
-
schedule
ScheduledFuture<?> schedule(Runnable task, long delay, TimeUnit unit)
Schedules a Runnable for one-shot action that becomes enabled after the given delay.- Returns:
- a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion
-
schedule
<V> ScheduledFuture<V> schedule(Callable<V> task, long delay, TimeUnit unit)
Schedules a Callable for one-shot action that becomes enabled after the given delay.- Returns:
- a ScheduledFuture that can be used to extract result or cancel
-
-