public final class EnhancedQueueExecutor extends AbstractExecutorService implements ManageableThreadPoolExecutorService
New instances of this thread pool are created by constructing and configuring a EnhancedQueueExecutor.Builder
instance, and calling
its build()
method.
Modifier and Type | Class and Description |
---|---|
static class |
EnhancedQueueExecutor.Builder
The builder class for an
EnhancedQueueExecutor . |
Modifier and Type | Field and Description |
---|---|
static boolean |
DISABLE_HINT
A global hint which establishes whether it is recommended to disable uses of
EnhancedQueueExecutor . |
Modifier and Type | Method and Description |
---|---|
void |
allowCoreThreadTimeOut(boolean value)
Establish whether core threads are allowed to time out.
|
boolean |
allowsCoreThreadTimeOut()
Determine whether core threads are allowed to time out.
|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
Wait for the thread pool to complete termination.
|
void |
execute(Runnable runnable)
Execute a task.
|
int |
getActiveCount()
Get an estimate of the number of threads which are currently doing work on behalf of the thread pool.
|
long |
getCompletedTaskCount()
Get an estimate of the number of tasks completed by this thread pool.
|
int |
getCorePoolSize()
Get the core pool size.
|
Thread.UncaughtExceptionHandler |
getExceptionHandler()
Get the exception handler to use for uncaught exceptions.
|
float |
getGrowthResistance()
Get the thread pool growth resistance.
|
Executor |
getHandoffExecutor()
Get the executor to delegate to in the event of task rejection.
|
long |
getKeepAliveTime(TimeUnit keepAliveUnits)
Get the thread keep-alive time.
|
int |
getLargestPoolSize()
Get an estimate of the peak number of threads that the pool has ever held.
|
int |
getLargestQueueSize()
Get an estimate of the peak size of the queue.
|
int |
getMaximumPoolSize()
Get the maximum pool size.
|
int |
getMaximumQueueSize()
Get the maximum queue size.
|
int |
getPoolSize()
Get an estimate of the current number of active threads in the pool.
|
int |
getQueueSize()
Get an estimate of the current queue size.
|
long |
getRejectedTaskCount()
Get an estimate of the total number of tasks ever rejected by this thread pool for any reason.
|
long |
getSubmittedTaskCount()
Get an estimate of the total number of tasks ever submitted to this thread pool.
|
StandardThreadPoolMXBean |
getThreadPoolMXBean()
Create or acquire an MXBean instance for this thread pool.
|
boolean |
isShutdown()
Determine whether shutdown was requested on this thread pool.
|
boolean |
isTerminated()
Determine whether shutdown has completed on this thread pool.
|
boolean |
isTerminating()
Determine if this thread pool is in the process of terminating but has not yet completed.
|
int |
prestartAllCoreThreads()
Start all core threads.
|
boolean |
prestartCoreThread()
Start an idle core thread.
|
void |
setCorePoolSize(int corePoolSize)
Set the core pool size.
|
void |
setExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)
Set the exception handler to use for uncaught exceptions.
|
void |
setGrowthResistance(float growthResistance)
Set the growth resistance factor.
|
void |
setHandoffExecutor(Executor handoffExecutor)
Set the executor to delegate to in the event of task rejection.
|
void |
setKeepAliveTime(long keepAliveTime,
TimeUnit keepAliveUnits)
Set the thread keep-alive time.
|
void |
setMaximumPoolSize(int maxPoolSize)
Set the maximum pool size.
|
void |
setMaximumQueueSize(int maxQueueSize)
Set the maximum queue size.
|
void |
setTerminationTask(Runnable terminationTask)
Set the termination task, overwriting any previous setting.
|
void |
shutdown()
Request that shutdown be initiated for this thread pool.
|
void |
shutdown(boolean interrupt)
Initiate shutdown of this thread pool.
|
List<Runnable> |
shutdownNow()
Attempt to stop the thread pool immediately by interrupting all running threads and de-queueing all pending
tasks.
|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public static final boolean DISABLE_HINT
EnhancedQueueExecutor
.
This hint defaults to false
but can be changed to true
by setting the jboss.threads.eqe.disable
property to true
before this class is initialized.public void execute(Runnable runnable)
public void shutdown()
shutdown(false)
; see that method for more information.shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
null
)public boolean isShutdown()
isShutdown
in interface ExecutorService
true
if shutdown was requested, false
otherwisepublic boolean isTerminated()
isTerminated
in interface ExecutorService
true
if shutdown has completed, false
otherwisepublic boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
false
is returned. If the calling thread is interrupted before the thread pool is terminated, then
an InterruptedException
is thrown.awaitTermination
in interface ExecutorService
timeout
- the amount of time to wait (must be ≥ 0)unit
- the unit of time to use for waiting (must not be null
)true
if the thread pool terminated within the given timeout, false
otherwiseInterruptedException
- if the calling thread was interrupted before either the time period elapsed or the pool terminated successfullypublic StandardThreadPoolMXBean getThreadPoolMXBean()
ManageableThreadPoolExecutorService
getThreadPoolMXBean
in interface ManageableThreadPoolExecutorService
null
)public void shutdown(boolean interrupt)
interrupt
parameter set to false
and the subsequent call sets it to true
, in
which case all threads in the pool will be interrupted.interrupt
- true
to request that currently-running tasks be interrupted; false
otherwisepublic boolean isTerminating()
true
if the thread pool is terminating, or false
if the thread pool is not terminating or has completed terminationpublic boolean prestartCoreThread()
true
if a core thread was started, or false
if all core threads were already running or
if the thread failed to be created for some other reasonpublic int prestartAllCoreThreads()
prestartCoreThread()
in a loop until it returns false
.public float getGrowthResistance()
0.0
indicates that tasks should
not be enqueued until the pool is completely full; a value of 1.0
indicates that tasks should always
be enqueued until the queue is completely full.Builder.getGrowthResistance()
public void setGrowthResistance(float growthResistance)
growthResistance
- the thread pool growth resistance (must be in the range 0.0f ≤ n ≤ 1.0f
)Builder.setGrowthResistance()
public int getCorePoolSize()
Builder.getCorePoolSize()
public void setCorePoolSize(int corePoolSize)
corePoolSize
- the core pool size (must be greater than or equal to 0, and less than 2^20)Builder.setCorePoolSize()
public int getMaximumPoolSize()
Builder.getMaximumPoolSize()
public void setMaximumPoolSize(int maxPoolSize)
maxPoolSize
- the maximum pool size (must be greater than or equal to 0, and less than 2^20)Builder.setMaximumPoolSize()
public boolean allowsCoreThreadTimeOut()
true
if core threads are allowed to time out, false
otherwiseBuilder.allowsCoreThreadTimeOut()
public void allowCoreThreadTimeOut(boolean value)
value
- true
if core threads are allowed to time out, false
otherwiseBuilder.allowCoreThreadTimeOut()
public long getKeepAliveTime(TimeUnit keepAliveUnits)
keepAliveUnits
- the unit in which the result should be expressed (must not be null
)Builder.getKeepAliveTime()
public void setKeepAliveTime(long keepAliveTime, TimeUnit keepAliveUnits)
keepAliveTime
- the thread keep-alive time (must be > 0)keepAliveUnits
- the unit in which the value is expressed (must not be null
)Builder.setKeepAliveTime()
public int getMaximumQueueSize()
Builder.getMaximumQueueSize()
public void setMaximumQueueSize(int maxQueueSize)
maxQueueSize
- the maximum queue size (must be ≥ 0)Builder.setMaximumQueueSize()
public Executor getHandoffExecutor()
null
)public void setHandoffExecutor(Executor handoffExecutor)
handoffExecutor
- the executor to delegate to in the event of task rejection (must not be null
)public Thread.UncaughtExceptionHandler getExceptionHandler()
null
)public void setExceptionHandler(Thread.UncaughtExceptionHandler exceptionHandler)
exceptionHandler
- the exception handler to use for uncaught exceptions (must not be null
)public void setTerminationTask(Runnable terminationTask)
terminationTask
- the termination task, or null
to perform no termination taskpublic int getQueueSize()
public int getLargestPoolSize()
public int getActiveCount()
public int getLargestQueueSize()
public long getSubmittedTaskCount()
public long getRejectedTaskCount()
public long getCompletedTaskCount()
public int getPoolSize()
Copyright © 2023 JBoss by Red Hat. All rights reserved.