Class AbstractThreadPoolProvider<E extends ThreadPoolExecutor>

All Implemented Interfaces:
Direct Known Subclasses:
ScheduledThreadPoolExecutorProvider, ThreadPoolExecutorProvider

public abstract class AbstractThreadPoolProvider<E extends ThreadPoolExecutor> extends Object implements AutoCloseable
Abstract thread pool executor provider.

This class provides a skeleton implementation for provisioning and basic lifecycle management of thread pool executors. Every instance of the concrete implementation of this provider class creates at most one shared and lazily initialized thread pool executor instance, which can be retrieved by invoking the getExecutor() method. This provider also makes sure that the provisioned thread pool executor instance is properly shut down when the managing provider instance is closed (in case it has not been already shut down).

At minimum, concrete subclasses of this provider are expected to implement the createExecutor(int, java.util.concurrent.ThreadFactory, java.util.concurrent.RejectedExecutionHandler) method that is used as a thread pool instance factory. The method is invoked lazily, with the first call to the getExecutor() method. The result returned from the createExecutor() method is cached internally and is used as a return value for subsequent calls to the getExecutor() method. This means, that createExecutor() method is guaranteed to be invoked at most once during the lifetime of any particular provider instance.

Marek Potociar