Class PinnedThreadPoolExecutor

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.util.concurrent.Executor, java.util.concurrent.ExecutorService

    public final class PinnedThreadPoolExecutor
    extends java.util.concurrent.ThreadPoolExecutor
    implements java.io.Closeable
    • Nested Class Summary

      • 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
      PinnedThreadPoolExecutor​(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, PinnedThreadFactory factory)
      Creates a new affinity aware PinnedThreadPoolExecutor with the given initial parameters.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      static java.util.concurrent.ExecutorService newFixedPinnedThreadPool​(int size, PinnedThreadFactory factory)
      Static factory methods for affinity aware fixed-size ExecutorService inception.
      static java.util.concurrent.ExecutorService newSinglePinnedThreadExecutor​(PinnedThreadFactory factory)
      Static factory methods for affinity aware single-thread ExecutorService inception.
      • 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, setRejectedExecutionHandler, 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

      • PinnedThreadPoolExecutor

        public PinnedThreadPoolExecutor​(int corePoolSize,
                                        int maximumPoolSize,
                                        long keepAliveTime,
                                        @Nonnull
                                        java.util.concurrent.TimeUnit unit,
                                        @Nonnull
                                        java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                                        @Nonnull
                                        PinnedThreadFactory factory)
        Creates a new affinity aware PinnedThreadPoolExecutor with the given initial parameters.
        Parameters:
        corePoolSize - the number of PinnedThread instances to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set
        maximumPoolSize - the maximum number of PinnedThread instances to allow in the pool
        keepAliveTime - 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.
        unit - the time unit for the keepAliveTime argument
        workQueue - the queue to use for holding tasks before they are executed. This queue will hold only the Runnable tasks submitted by the execute method.
        factory - the PinnedThread factory to use when the executor creates a new thread
    • Method Detail

      • newSinglePinnedThreadExecutor

        public static java.util.concurrent.ExecutorService newSinglePinnedThreadExecutor​(@Nonnull
                                                                                         PinnedThreadFactory factory)
        Static factory methods for affinity aware single-thread ExecutorService inception.
        Parameters:
        factory - the PinnedThreadFactory used create affinity aware PinnedThread instances
        Returns:
        the affinity aware ExecutorService
      • newFixedPinnedThreadPool

        public static java.util.concurrent.ExecutorService newFixedPinnedThreadPool​(int size,
                                                                                    @Nonnull
                                                                                    PinnedThreadFactory factory)
        Static factory methods for affinity aware fixed-size ExecutorService inception.
        Parameters:
        size - number of PinnedThread instances to maintain in the pool
        factory - the PinnedThreadFactory used create affinity aware PinnedThread instances
        Returns:
        the affinity aware ExecutorService
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable