Package org.jboss.threads.management
Interface StandardThreadPoolMXBean
-
public interface StandardThreadPoolMXBeanAn MXBean which contains the attributes and operations found on all standard thread pools.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intgetActiveCount()Get an estimate of the current number of active (busy) threads.longgetCompletedTaskCount()Get an estimate of the number of tasks completed by this thread pool.intgetCorePoolSize()Get the core pool size.floatgetGrowthResistance()Get the pool size growth resistance factor.longgetKeepAliveTimeSeconds()Get the thread keep-alive time, in seconds.intgetLargestPoolSize()Get an estimate of the peak number of threads that the pool has ever held.intgetLargestQueueSize()Get an estimate of the peak size of the queue, if any.intgetMaximumPoolSize()Get the maximum pool size.intgetMaximumQueueSize()Get the maximum queue size for this thread pool.intgetPoolSize()Get an estimate of the current number of active threads in the pool.intgetQueueSize()Get an estimate of the current queue size, if any.longgetRejectedTaskCount()Get an estimate of the total number of tasks ever rejected by this thread pool for any reason.default longgetSpinMissCount()Get the number of spin misses that have occurred.longgetSubmittedTaskCount()Get an estimate of the total number of tasks ever submitted to this thread pool.booleanisAllowCoreThreadTimeOut()Determine whether core threads are allowed to time out.booleanisCorePoolSizeSupported()Determine whether this implementation supports a separate core pool size.booleanisCoreThreadPrestartSupported()Determine whether this thread pool allows manual pre-start of core threads.booleanisGrowthResistanceSupported()Determine whether the thread pool supports a growth resistance factor.booleanisQueueBounded()Determine whether there is a bounded queue backing this thread pool.booleanisQueueSizeModifiable()Determine whether the maximum queue size is modifiable.booleanisShutdown()Determine whether shutdown was requested.booleanisTerminated()Determine whether shutdown is complete.booleanisTerminating()Determine whether shutdown is in progress.intprestartAllCoreThreads()Attempt to start all core threads.booleanprestartCoreThread()Attempt to start a core thread without submitting work to it.voidsetAllowCoreThreadTimeOut(boolean value)Establish whether core threads are allowed to time out.voidsetCorePoolSize(int corePoolSize)Set the core pool size.voidsetGrowthResistance(float value)Set the pool size growth resistance factor, if supported.voidsetKeepAliveTimeSeconds(long seconds)Set the thread keep-alive time, in seconds.voidsetMaximumPoolSize(int maxPoolSize)Set the maximum pool size.voidsetMaximumQueueSize(int size)Set the maximum queue size for this thread pool.
-
-
-
Method Detail
-
getGrowthResistance
float getGrowthResistance()
Get the pool size growth resistance factor. If the thread pool does not support growth resistance, then0.0(no resistance) is returned.- Returns:
- the growth resistance factor (
0.0 ≤ n ≤ 1.0)
-
setGrowthResistance
void setGrowthResistance(float value)
Set the pool size growth resistance factor, if supported.- Parameters:
value- the growth resistance factor (0.0 ≤ n ≤ 1.0)
-
isGrowthResistanceSupported
boolean isGrowthResistanceSupported()
Determine whether the thread pool supports a growth resistance factor.- Returns:
trueif the growth resistance factor is supported,falseotherwise
-
getCorePoolSize
int getCorePoolSize()
Get the core pool size. This is the size below which new threads will always be created if no idle threads are available. If the thread pool does not support a separate core pool size, this size will match the maximum size.- Returns:
- the core pool size
-
setCorePoolSize
void setCorePoolSize(int corePoolSize)
Set the core pool size. If the configured maximum pool size is less than the configured core size, the core size will be reduced to match the maximum size when the thread pool is constructed. If the thread pool does not support a separate core pool size, this setting will be ignored.- Parameters:
corePoolSize- the core pool size (must be greater than or equal to 0)
-
isCorePoolSizeSupported
boolean isCorePoolSizeSupported()
Determine whether this implementation supports a separate core pool size.- Returns:
trueif a separate core size is supported;falseotherwise
-
prestartCoreThread
boolean prestartCoreThread()
Attempt to start a core thread without submitting work to it.- Returns:
trueif the thread was started, orfalseif the pool is filled to the core size, the thread could not be created, or prestart of core threads is not supported.
-
prestartAllCoreThreads
int prestartAllCoreThreads()
Attempt to start all core threads. This is usually equivalent to callingprestartCoreThread()in a loop until it returnsfalseand counting thetrueresults.- Returns:
- the number of started core threads (may be 0)
-
isCoreThreadPrestartSupported
boolean isCoreThreadPrestartSupported()
Determine whether this thread pool allows manual pre-start of core threads.- Returns:
trueif pre-starting core threads is supported,falseotherwise
-
getMaximumPoolSize
int getMaximumPoolSize()
Get the maximum pool size. This is the absolute upper limit to the size of the thread pool.- Returns:
- the maximum pool size
-
setMaximumPoolSize
void setMaximumPoolSize(int maxPoolSize)
Set the maximum pool size. If the configured maximum pool size is less than the configured core size, the core size will be reduced to match the maximum size when the thread pool is constructed.- Parameters:
maxPoolSize- the maximum pool size (must be greater than or equal to 0)
-
getPoolSize
int getPoolSize()
Get an estimate of the current number of active threads in the pool.- Returns:
- an estimate of the current number of active threads in the pool
-
getLargestPoolSize
int getLargestPoolSize()
Get an estimate of the peak number of threads that the pool has ever held.- Returns:
- an estimate of the peak number of threads that the pool has ever held
-
getActiveCount
int getActiveCount()
Get an estimate of the current number of active (busy) threads.- Returns:
- an estimate of the active count
-
isAllowCoreThreadTimeOut
boolean isAllowCoreThreadTimeOut()
Determine whether core threads are allowed to time out. A "core thread" is defined as any thread in the pool when the pool size is below the pool's core pool size. If the thread pool does not support a separate core pool size, this method should returnfalse.This method is named differently from the typical
allowsCoreThreadTimeOut()in order to accommodate the requirements of MXBean attribute methods.- Returns:
trueif core threads are allowed to time out,falseotherwise
-
setAllowCoreThreadTimeOut
void setAllowCoreThreadTimeOut(boolean value)
Establish whether core threads are allowed to time out. A "core thread" is defined as any thread in the pool when the pool size is below the pool's core pool size. If the thread pool does not support a separate core pool size, the value is ignored.This method is named differently from the typical
allowCoreThreadTimeOut(boolean)in order to accommodate the requirements of MXBean attribute methods.- Parameters:
value-trueif core threads are allowed to time out,falseotherwise
-
getKeepAliveTimeSeconds
long getKeepAliveTimeSeconds()
Get the thread keep-alive time, in seconds.This method differs from the typical
getKeepAliveTime(TimeUnit)due to the inability to send in a time units parameter on an MXBean attribute. As such, the unit is hard-coded to seconds.- Returns:
- the thread keep-alive time, in seconds
-
setKeepAliveTimeSeconds
void setKeepAliveTimeSeconds(long seconds)
Set the thread keep-alive time, in seconds.This method differs from the typical
getKeepAliveTime(TimeUnit)due to the inability to send in a time units parameter on an MXBean attribute. As such, the unit is hard-coded to seconds.- Parameters:
seconds- the thread keep-alive time, in seconds (must be greater than or equal to 0)
-
getMaximumQueueSize
int getMaximumQueueSize()
Get the maximum queue size for this thread pool. If there is no queue or it is not bounded,Integer.MAX_VALUEis returned.- Returns:
- the maximum queue size
-
setMaximumQueueSize
void setMaximumQueueSize(int size)
Set the maximum queue size for this thread pool. If the new maximum queue size is smaller than the current queue size, there is no effect other than preventing tasks from being enqueued until the size decreases below the maximum again. If changing the maximum queue size is not supported, or there is no bounded backing queue, then the value is ignored.- Parameters:
size- the maximum queue size for this thread pool
-
getQueueSize
int getQueueSize()
Get an estimate of the current queue size, if any. If no backing queue exists, or its size cannot be determined, this method will return 0.- Returns:
- an estimate of the current queue size
-
getLargestQueueSize
int getLargestQueueSize()
Get an estimate of the peak size of the queue, if any. If no backing queue exists, or its size cannot be determined, this method will return 0.- Returns:
- an estimate of the peak size of the queue
-
isQueueBounded
boolean isQueueBounded()
Determine whether there is a bounded queue backing this thread pool.- Returns:
trueif there is a bounded backing queue,falseotherwise
-
isQueueSizeModifiable
boolean isQueueSizeModifiable()
Determine whether the maximum queue size is modifiable.- Returns:
trueif the queue size is modifiable, false otherwise
-
isShutdown
boolean isShutdown()
Determine whether shutdown was requested.- Returns:
trueif shutdown was requested,falseotherwise
-
isTerminating
boolean isTerminating()
Determine whether shutdown is in progress.- Returns:
trueif shutdown is in progress,falseotherwise
-
isTerminated
boolean isTerminated()
Determine whether shutdown is complete.- Returns:
trueif shutdown is complete,falseotherwise
-
getSubmittedTaskCount
long getSubmittedTaskCount()
Get an estimate of the total number of tasks ever submitted to this thread pool. This number may be zero if the underlying thread pool does not support this metric.- Returns:
- an estimate of the total number of tasks ever submitted to this thread pool
-
getRejectedTaskCount
long getRejectedTaskCount()
Get an estimate of the total number of tasks ever rejected by this thread pool for any reason. This number may be zero if the underlying thread pool does not support this metric.- Returns:
- an estimate of the total number of tasks ever rejected by this thread pool
-
getCompletedTaskCount
long getCompletedTaskCount()
Get an estimate of the number of tasks completed by this thread pool. This number may be zero if the underlying thread pool does not support this metric.- Returns:
- an estimate of the number of tasks completed by this thread pool
-
getSpinMissCount
default long getSpinMissCount()
Get the number of spin misses that have occurred. Spin misses indicate that contention is not being properly handled by the thread pool.- Returns:
- an estimate of the number of spin misses
-
-