Package org.apache.cassandra.concurrent
Interface ExecutorBuilder<E extends ExecutorService>
- All Known Implementing Classes:
ThreadPoolExecutorBuilder
public interface ExecutorBuilder<E extends ExecutorService>
Configure an executor before creating it.
See
ThreadPoolExecutorBuilder-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the configured executorUse the system default thread group for the threads we create.Core threads for the executor built by this factory will never timeout (default for single threaded builders).withKeepAlive(long keepAlive, TimeUnit keepAliveUnits) Threads for the executor built by this factory will timeout (terminate) after the specified period.withQueueLimit(int queueLimit) The executor built by this factory will limit the number of queued tasks; default is unlimited.withRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) Set theRejectedExecutionHandlerfor the executor built by this factory.withThreadGroup(ThreadGroup threadGroup) Threads for the executor built by this factory will all be (transitively) members ofthreadGroup, but may directly reside in a child thread group.withThreadPriority(int threadPriority) Specify the priority of threads that service the executor built by this factory (default toThread.NORM_PRIORITY)withUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Set theThread.UncaughtExceptionHandlerfor threads that service executors built by this factory.
-
Method Details
-
withKeepAlive
Threads for the executor built by this factory will timeout (terminate) after the specified period. -
withKeepAlive
ExecutorBuilder<E> withKeepAlive()Core threads for the executor built by this factory will never timeout (default for single threaded builders). Note that there is ordinarily no difference between core and non-core threads; only when the queue limit is zero do we create non-core threads. -
withThreadPriority
Specify the priority of threads that service the executor built by this factory (default toThread.NORM_PRIORITY) -
withThreadGroup
Threads for the executor built by this factory will all be (transitively) members ofthreadGroup, but may directly reside in a child thread group. -
withDefaultThreadGroup
ExecutorBuilder<E> withDefaultThreadGroup()Use the system default thread group for the threads we create. This is used only for testing, so that we do not hold onto a transitive global reference to all threads. -
withQueueLimit
The executor built by this factory will limit the number of queued tasks; default is unlimited. Once the queue limit is reached and all threads are executing tasks will be rejected (seewithRejectedExecutionHandler(RejectedExecutionHandler)) -
withRejectedExecutionHandler
Set theRejectedExecutionHandlerfor the executor built by this factory. By default this is executor-specific, either:ThreadPoolExecutorBase.blockingExecutionHandlerScheduledThreadPoolExecutorPlus.rejectedExecutionHandler- and maybe wrapped by
ThreadPoolExecutorJMXAdapter.rejectedExecutionHandler(org.apache.cassandra.metrics.ThreadPoolMetrics, java.util.concurrent.RejectedExecutionHandler) -
withUncaughtExceptionHandler
ExecutorBuilder<E> withUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) Set theThread.UncaughtExceptionHandlerfor threads that service executors built by this factory. By defaultJVMStabilityInspector.uncaughtException(Thread, Throwable) -
build
E build()Build the configured executor
-