Class Executors
java.lang.Object
org.hibernate.search.batchindexing.Executors
Helper class to create threads;
these threads are grouped and named to be identified in a profiler.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA handler for rejected tasks that will have the caller block until space is available. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadPoolExecutornewFixedThreadPool(int threads, String groupname) Creates a new fixed size ThreadPoolExecutor.static ThreadPoolExecutornewFixedThreadPool(int threads, String groupname, int queueSize) Creates a new fixed size ThreadPoolExecutor
-
Field Details
-
QUEUE_MAX_LENGTH
public static final int QUEUE_MAX_LENGTH- See Also:
-
-
Constructor Details
-
Executors
public Executors()
-
-
Method Details
-
newFixedThreadPool
Creates a new fixed size ThreadPoolExecutor. It's using a blockingqueue of maximum 1000 elements and the rejection policy is set to CallerRunsPolicy for the case the queue is full. These settings are required to cap the queue, to make sure the timeouts are reasonable for most jobs.- Parameters:
threads- the number of threadsgroupname- a label to identify the threadpool; useful for profiling.- Returns:
- the new ExecutorService
-
newFixedThreadPool
Creates a new fixed size ThreadPoolExecutor- Parameters:
threads- the number of threadsgroupname- a label to identify the threadpool; useful for profiling.queueSize- the size of the queue to store Runnables when all threads are busy- Returns:
- the new ExecutorService
-