Code example for ScheduledThreadPoolExecutor

Methods: setKeepAliveTimesetMaximumPoolSize

0
 * @author Johan Siebens 
 */ 
public abstract class AbstractScheduledThreadPoolExecutor<A extends AbstractScheduledThreadPoolExecutor<A>> extends AbstractThreadPoolBuilder<A> { 
 
    protected final ScheduledExecutorService createScheduledExecutorService() {
        ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(corePoolSize, createThreadFactory());
        scheduler.setMaximumPoolSize(maxPoolSize);
        scheduler.setKeepAliveTime(keepAlive, keepAliveUnit);
        return scheduler;
    } 
 
    protected final ScheduledExecutorService createAndRegisterScheduledExecutorService(DatoliteContext context) {
        return context.register(new DisposableExecutorService<>(createScheduledExecutorService())).get();
    } 
 
}