Package io.ebeaninternal.server.core
Class DefaultBackgroundExecutor
- java.lang.Object
-
- io.ebeaninternal.server.core.DefaultBackgroundExecutor
-
- All Implemented Interfaces:
BackgroundExecutor
,SpiBackgroundExecutor
public class DefaultBackgroundExecutor extends Object implements SpiBackgroundExecutor
The default implementation of the BackgroundExecutor.
-
-
Constructor Summary
Constructors Constructor Description DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix)
Construct the default implementation of BackgroundExecutor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(Runnable r)
Execute a Runnable using a background thread.void
executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit)
Execute a task periodically additionally with an initial delay different from delay.void
executePeriodically(Runnable r, long delay, TimeUnit unit)
Execute a task periodically with a fixed delay between each execution.ScheduledFuture<?>
schedule(Runnable r, long delay, TimeUnit unit)
Schedules a Runnable for one-shot action that becomes enabled after the given delay.<V> ScheduledFuture<V>
schedule(Callable<V> c, long delay, TimeUnit unit)
Schedules a Callable for one-shot action that becomes enabled after the given delay.void
shutdown()
Shutdown any associated thread pools.
-
-
-
Constructor Detail
-
DefaultBackgroundExecutor
public DefaultBackgroundExecutor(int schedulePoolSize, int shutdownWaitSeconds, String namePrefix)
Construct the default implementation of BackgroundExecutor.
-
-
Method Detail
-
execute
public void execute(Runnable r)
Execute a Runnable using a background thread.- Specified by:
execute
in interfaceBackgroundExecutor
-
executePeriodically
public void executePeriodically(Runnable r, long delay, TimeUnit unit)
Description copied from interface:BackgroundExecutor
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)
- Specified by:
executePeriodically
in interfaceBackgroundExecutor
-
executePeriodically
public void executePeriodically(Runnable r, long initialDelay, long delay, TimeUnit unit)
Description copied from interface:BackgroundExecutor
Execute a task periodically additionally with an initial delay different from delay.- Specified by:
executePeriodically
in interfaceBackgroundExecutor
-
schedule
public ScheduledFuture<?> schedule(Runnable r, long delay, TimeUnit unit)
Description copied from interface:BackgroundExecutor
Schedules a Runnable for one-shot action that becomes enabled after the given delay.- Specified by:
schedule
in interfaceBackgroundExecutor
- Returns:
- a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion
-
schedule
public <V> ScheduledFuture<V> schedule(Callable<V> c, long delay, TimeUnit unit)
Description copied from interface:BackgroundExecutor
Schedules a Callable for one-shot action that becomes enabled after the given delay.- Specified by:
schedule
in interfaceBackgroundExecutor
- Returns:
- a ScheduledFuture that can be used to extract result or cancel
-
shutdown
public void shutdown()
Description copied from interface:SpiBackgroundExecutor
Shutdown any associated thread pools.- Specified by:
shutdown
in interfaceSpiBackgroundExecutor
-
-