public static final class ExecutorFactory.Default extends NamedThreadFactory.MetaFactory implements ExecutorFactory
ExecutorFactory.Default, ExecutorFactory.Global, ExecutorFactory.LocalAwareSubFactory, ExecutorFactory.LocalAwareSubFactoryWithJMX, ExecutorFactory.SimulatorSemantics
ExecutorBuilderFactory.Jmxable<E extends ExecutorPlus,S extends SequentialExecutorPlus>
contextClassLoader, threadGroup, uncaughtExceptionHandler
Constructor and Description |
---|
Default(java.lang.ClassLoader contextClassLoader,
java.lang.ThreadGroup threadGroup,
java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler) |
Modifier and Type | Method and Description |
---|---|
ExecutorBuilder<ThreadPoolExecutorPlus> |
configurePooled(java.lang.String name,
int threads)
Configure a pooled executor with the requested number of threads
|
ExecutorBuilder<SingleThreadExecutorPlus> |
configureSequential(java.lang.String name)
Configure a sequential (single threaded) executor
|
Interruptible |
infiniteLoop(java.lang.String name,
Interruptible.Task task,
InfiniteLoopExecutor.SimulatorSafe simulatorSafe,
InfiniteLoopExecutor.Daemon daemon,
InfiniteLoopExecutor.Interrupts interrupts)
Create and start a new InfiniteLoopExecutor to repeatedly invoke
runnable . |
ExecutorFactory.LocalAwareSubFactory |
localAware() |
java.lang.ThreadGroup |
newThreadGroup(java.lang.String name)
Create a new thread group for use with builders - this thread group will be situated within
this factory's parent thread group, and may be supplied to multiple executor builders.
|
ScheduledExecutorPlus |
scheduled(boolean executeOnShutdown,
java.lang.String name,
int priority,
ExecutorFactory.SimulatorSemantics simulatorSemantics) |
java.lang.Thread |
startThread(java.lang.String name,
java.lang.Runnable runnable,
InfiniteLoopExecutor.Daemon daemon)
Create and start a new thread to execute
runnable |
ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus> |
withJmx(java.lang.String jmxPath) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
infiniteLoop, scheduled, scheduled, scheduled, scheduled, startThread
withJmxInternal
pooled, sequential
public Default(java.lang.ClassLoader contextClassLoader, java.lang.ThreadGroup threadGroup, java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
public ExecutorFactory.LocalAwareSubFactory localAware()
localAware
in interface ExecutorFactory
ExecutorLocals
to the executing threadpublic ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus> withJmx(java.lang.String jmxPath)
withJmx
in interface ExecutorBuilderFactory.Jmxable<ExecutorPlus,SequentialExecutorPlus>
public ExecutorBuilder<SingleThreadExecutorPlus> configureSequential(java.lang.String name)
ExecutorBuilderFactory
configureSequential
in interface ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus>
public ExecutorBuilder<ThreadPoolExecutorPlus> configurePooled(java.lang.String name, int threads)
ExecutorBuilderFactory
configurePooled
in interface ExecutorBuilderFactory<ExecutorPlus,SequentialExecutorPlus>
public ScheduledExecutorPlus scheduled(boolean executeOnShutdown, java.lang.String name, int priority, ExecutorFactory.SimulatorSemantics simulatorSemantics)
scheduled
in interface ExecutorFactory
executeOnShutdown
- if false, waiting tasks will be cancelled on shutdownname
- the name of the executor, the executor's thread group, and of any worker threadspriority
- the thread priority of workerssimulatorSemantics
- indicate special semantics for the executor under simulationScheduledExecutorPlus
public java.lang.Thread startThread(java.lang.String name, java.lang.Runnable runnable, InfiniteLoopExecutor.Daemon daemon)
ExecutorFactory
runnable
startThread
in interface ExecutorFactory
name
- the name of the threadrunnable
- the task to executedaemon
- flag to indicate whether the thread should be a daemon or notpublic Interruptible infiniteLoop(java.lang.String name, Interruptible.Task task, InfiniteLoopExecutor.SimulatorSafe simulatorSafe, InfiniteLoopExecutor.Daemon daemon, InfiniteLoopExecutor.Interrupts interrupts)
ExecutorFactory
runnable
.
On shutdown, the executing thread will be interrupted; to support clean shutdown
runnable
should propagate InterruptedException
infiniteLoop
in interface ExecutorFactory
name
- the name of the thread used to invoke the task repeatedlytask
- the task to execute repeatedlysimulatorSafe
- flag indicating if the loop thread can be intercepted / rescheduled during cluster simulationdaemon
- flag to indicate whether the loop thread should be a daemon thread or notinterrupts
- flag to indicate whether to synchronize interrupts of the task execution thread
using the task's monitor this can be used to prevent interruption while performing
IO operations which forbid interrupted threads.
See: org.apache.cassandra.db.commitlog.AbstractCommitLogSegmentManager::start
public java.lang.ThreadGroup newThreadGroup(java.lang.String name)
ExecutorFactory
newThreadGroup
in interface ExecutorFactory
Copyright © 2009-2022 The Apache Software Foundation