Interface ThreadPoolProvider
-
public interface ThreadPoolProvider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ThreadPoolExecutor
newFixedThreadPool(int threads, String threadNamePrefix)
Creates a new fixed sizeThreadPoolExecutor
.ThreadPoolExecutor
newFixedThreadPool(int threads, String threadNamePrefix, int queueSize)
Creates a new fixed sizeThreadPoolExecutor
.ScheduledExecutorService
newScheduledExecutor(int threads, String threadNamePrefix)
Creates a new fixed sizeScheduledExecutorService
.ThreadProvider
threadProvider()
-
-
-
Method Detail
-
threadProvider
ThreadProvider threadProvider()
- Returns:
- The underlying thread provider.
-
newFixedThreadPool
ThreadPoolExecutor newFixedThreadPool(int threads, String threadNamePrefix)
Creates a new fixed sizeThreadPoolExecutor
.It's using a blocking queue of maximum 1000 elements and the rejection policy is set to block until the queue can accept the task. These settings are required to cap the queue, to make sure the timeouts are reasonable for most jobs.
- Parameters:
threads
- the number of threadsthreadNamePrefix
- a label to identify the threads; useful for profiling.- Returns:
- the new ExecutorService
-
newFixedThreadPool
ThreadPoolExecutor newFixedThreadPool(int threads, String threadNamePrefix, int queueSize)
Creates a new fixed sizeThreadPoolExecutor
.It's using a blocking queue of maximum
queueSize
elements and the rejection policy is set to block until the queue can accept the task. These settings are required to cap the queue, to make sure the timeouts are reasonable for most jobs.- Parameters:
threads
- the number of threadsthreadNamePrefix
- a label to identify the threads; useful for profiling.queueSize
- the size of the queue to store Runnables when all threads are busy- Returns:
- the new ExecutorService
-
newScheduledExecutor
ScheduledExecutorService newScheduledExecutor(int threads, String threadNamePrefix)
Creates a new fixed sizeScheduledExecutorService
.The queue size is not capped, so users should take care of checking they submit a reasonable amount of tasks.
- Parameters:
threads
- the number of threadsthreadNamePrefix
- a label to identify the threads; useful for profiling.- Returns:
- the new ExecutorService
-
-