Class UnboundedGrowingThreadPoolExecutor

  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public class UnboundedGrowingThreadPoolExecutor
    extends java.util.concurrent.ThreadPoolExecutor
    A ThreadPoolExecutor that increases the threads in the pool even if the queue is not full.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  UnboundedGrowingThreadPoolExecutor.PutBackExecutionHandler
      Custom handler of the rejection event to make sure the rejected item are put back to the queue
      private static class  UnboundedGrowingThreadPoolExecutor.TransferOnOfferBlockingQueue
      A blocking queue implementation that always tries to transfer the items offered
      • Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

        java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
    • Constructor Summary

      Constructors 
      Constructor Description
      UnboundedGrowingThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, java.time.Duration keepAlive, java.lang.String threadNamePrefix)
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void setRejectedExecutionHandler​(java.util.concurrent.RejectedExecutionHandler handlerIn)  
      • Methods inherited from class java.util.concurrent.ThreadPoolExecutor

        afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setThreadFactory, shutdown, shutdownNow, terminated, toString
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • UnboundedGrowingThreadPoolExecutor

        public UnboundedGrowingThreadPoolExecutor​(int corePoolSize,
                                                  int maximumPoolSize,
                                                  java.time.Duration keepAlive,
                                                  java.lang.String threadNamePrefix)
        Default constructor
        Parameters:
        corePoolSize - the number of core threads
        maximumPoolSize - the maximum number of threads to allow in the pool
        keepAlive - when the number of threads is greater than the core, this is the maximum time that excess idle threads will wait for new tasks before terminating.
        threadNamePrefix - the prefix to use for the name of the threads part of the pool
    • Method Detail

      • setRejectedExecutionHandler

        public void setRejectedExecutionHandler​(java.util.concurrent.RejectedExecutionHandler handlerIn)
        Overrides:
        setRejectedExecutionHandler in class java.util.concurrent.ThreadPoolExecutor