public class DefaultBackgroundExecutor extends Object implements SpiBackgroundExecutor
| Constructor and Description |
|---|
DefaultBackgroundExecutor(int schedulePoolSize,
int corePoolSize,
long keepAliveSecs,
int shutdownWaitSeconds,
String namePrefix)
Construct the default implementation of BackgroundExecutor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
execute(Runnable r)
Execute a Runnable using a background thread.
|
void |
executePeriodically(Runnable r,
long delay,
TimeUnit unit)
Execute a task periodically with a fixed delay between each execution.
|
void |
shutdown()
Shutdown any associated thread pools.
|
public DefaultBackgroundExecutor(int schedulePoolSize,
int corePoolSize,
long keepAliveSecs,
int shutdownWaitSeconds,
String namePrefix)
mainPoolSize - the core size of the thread pool.keepAliveSecs - the time in seconds idle threads are keep aliveshutdownWaitSeconds - the time in seconds allowed for the pool to shutdown nicely.
After this the pool is forced to shutdown.public void execute(Runnable r)
execute in interface BackgroundExecutorpublic void executePeriodically(Runnable r, long delay, TimeUnit unit)
BackgroundExecutorFor 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 in interface BackgroundExecutorpublic void shutdown()
SpiBackgroundExecutorshutdown in interface SpiBackgroundExecutorCopyright © 2014. All Rights Reserved.