Interface StandardThreadPoolMXBean


  • public interface StandardThreadPoolMXBean
    An MXBean which contains the attributes and operations found on all standard thread pools.
    • Method Detail

      • getGrowthResistance

        float getGrowthResistance()
        Get the pool size growth resistance factor. If the thread pool does not support growth resistance, then 0.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:
        true if the growth resistance factor is supported, false otherwise
      • 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:
        true if a separate core size is supported; false otherwise
      • prestartCoreThread

        boolean prestartCoreThread()
        Attempt to start a core thread without submitting work to it.
        Returns:
        true if the thread was started, or false if 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 calling prestartCoreThread() in a loop until it returns false and counting the true results.
        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:
        true if pre-starting core threads is supported, false otherwise
      • 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 return false.

        This method is named differently from the typical allowsCoreThreadTimeOut() in order to accommodate the requirements of MXBean attribute methods.

        Returns:
        true if core threads are allowed to time out, false otherwise
      • 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 - true if core threads are allowed to time out, false otherwise
      • 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_VALUE is 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:
        true if there is a bounded backing queue, false otherwise
      • isQueueSizeModifiable

        boolean isQueueSizeModifiable()
        Determine whether the maximum queue size is modifiable.
        Returns:
        true if the queue size is modifiable, false otherwise
      • isShutdown

        boolean isShutdown()
        Determine whether shutdown was requested.
        Returns:
        true if shutdown was requested, false otherwise
      • isTerminating

        boolean isTerminating()
        Determine whether shutdown is in progress.
        Returns:
        true if shutdown is in progress, false otherwise
      • isTerminated

        boolean isTerminated()
        Determine whether shutdown is complete.
        Returns:
        true if shutdown is complete, false otherwise
      • 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