public class ThreadPoolExecutorBuilder<E extends ExecutorPlus> extends NamedThreadFactory.MetaFactory implements ExecutorBuilder<E>
ThreadPoolExecutorPlus
, applying Cassandra's best practices by default
keepAlive
time in keepAliveUnits
ThreadGroup
, which may be configurably a child of a specified ThreadGroup
descended from the same parent of the NamedThreadFactory.MetaFactory
RejectedExecutionHandler
is implementation dependent, but may be overridden
Thread.UncaughtExceptionHandler
is inherited from NamedThreadFactory.MetaFactory
, which in turn receives it
from the ExecutorBuilderFactory
contextClassLoader, threadGroup, uncaughtExceptionHandler
Modifier | Constructor and Description |
---|---|
protected |
ThreadPoolExecutorBuilder(java.util.function.Function<ThreadPoolExecutorBuilder<E>,E> constructor,
java.lang.ClassLoader contextClassLoader,
java.lang.ThreadGroup overrideThreadGroup,
java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler,
java.lang.String name,
int threads) |
Modifier and Type | Method and Description |
---|---|
E |
build()
Build the configured executor
|
ExecutorBuilder<E> |
withDefaultThreadGroup()
Use the system default thread group for the threads we create.
|
ThreadPoolExecutorBuilder<E> |
withKeepAlive()
Core threads for the executor built by this factory will never timeout (default for single threaded builders).
|
ThreadPoolExecutorBuilder<E> |
withKeepAlive(long keepAlive,
java.util.concurrent.TimeUnit keepAliveUnits)
Threads for the executor built by this factory will timeout (terminate) after the specified period.
|
ThreadPoolExecutorBuilder<E> |
withQueueLimit(int queueLimit)
The executor built by this factory will limit the number of queued tasks; default is unlimited.
|
ThreadPoolExecutorBuilder<E> |
withRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
Set the
RejectedExecutionHandler for the executor built by this factory. |
ExecutorBuilder<E> |
withThreadGroup(java.lang.ThreadGroup threadGroup)
Threads for the executor built by this factory will all be (transitively) members of
threadGroup ,
but may directly reside in a child thread group. |
ThreadPoolExecutorBuilder<E> |
withThreadPriority(int threadPriority)
Specify the priority of threads that service the executor built by this factory (default to
Thread.NORM_PRIORITY ) |
ThreadPoolExecutorBuilder<E> |
withUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Set the
Thread.UncaughtExceptionHandler for threads that service executors built by this factory. |
protected ThreadPoolExecutorBuilder(java.util.function.Function<ThreadPoolExecutorBuilder<E>,E> constructor, java.lang.ClassLoader contextClassLoader, java.lang.ThreadGroup overrideThreadGroup, java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler, java.lang.String name, int threads)
public ThreadPoolExecutorBuilder<E> withKeepAlive(long keepAlive, java.util.concurrent.TimeUnit keepAliveUnits)
ExecutorBuilder
withKeepAlive
in interface ExecutorBuilder<E extends ExecutorPlus>
public ThreadPoolExecutorBuilder<E> withKeepAlive()
ExecutorBuilder
withKeepAlive
in interface ExecutorBuilder<E extends ExecutorPlus>
public ThreadPoolExecutorBuilder<E> withThreadPriority(int threadPriority)
ExecutorBuilder
Thread.NORM_PRIORITY
)withThreadPriority
in interface ExecutorBuilder<E extends ExecutorPlus>
public ExecutorBuilder<E> withThreadGroup(java.lang.ThreadGroup threadGroup)
ExecutorBuilder
threadGroup
,
but may directly reside in a child thread group.withThreadGroup
in interface ExecutorBuilder<E extends ExecutorPlus>
public ExecutorBuilder<E> withDefaultThreadGroup()
ExecutorBuilder
withDefaultThreadGroup
in interface ExecutorBuilder<E extends ExecutorPlus>
public ThreadPoolExecutorBuilder<E> withQueueLimit(int queueLimit)
ExecutorBuilder
ExecutorBuilder.withRejectedExecutionHandler(RejectedExecutionHandler)
)withQueueLimit
in interface ExecutorBuilder<E extends ExecutorPlus>
public ThreadPoolExecutorBuilder<E> withRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler rejectedExecutionHandler)
ExecutorBuilder
RejectedExecutionHandler
for the executor built by this factory.
By default this is executor-specific, either:
ThreadPoolExecutorBase.blockingExecutionHandler
ScheduledThreadPoolExecutorPlus.rejectedExecutionHandler
ThreadPoolExecutorJMXAdapter.rejectedExecutionHandler(org.apache.cassandra.metrics.ThreadPoolMetrics, java.util.concurrent.RejectedExecutionHandler)
withRejectedExecutionHandler
in interface ExecutorBuilder<E extends ExecutorPlus>
public ThreadPoolExecutorBuilder<E> withUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
ExecutorBuilder
Thread.UncaughtExceptionHandler
for threads that service executors built by this factory.
By default JVMStabilityInspector.uncaughtException(Thread, Throwable)
withUncaughtExceptionHandler
in interface ExecutorBuilder<E extends ExecutorPlus>
public E build()
ExecutorBuilder
build
in interface ExecutorBuilder<E extends ExecutorPlus>
Copyright © 2009- The Apache Software Foundation