Class PinnedThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- org.sheinbergon.needle.concurrent.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 awarePinnedThreadPoolExecutorwith the given initial parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static java.util.concurrent.ExecutorServicenewFixedPinnedThreadPool(int size, PinnedThreadFactory factory)Static factory methods for affinity aware fixed-sizeExecutorServiceinception.static java.util.concurrent.ExecutorServicenewSinglePinnedThreadExecutor(PinnedThreadFactory factory)Static factory methods for affinity aware single-threadExecutorServiceinception.-
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
-
-
-
-
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 awarePinnedThreadPoolExecutorwith the given initial parameters.- Parameters:
corePoolSize- the number ofPinnedThreadinstances to keep in the pool, even if they are idle, unlessallowCoreThreadTimeOutis setmaximumPoolSize- the maximum number ofPinnedThreadinstances to allow in the poolkeepAliveTime- 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 thekeepAliveTimeargumentworkQueue- the queue to use for holding tasks before they are executed. This queue will hold only theRunnabletasks submitted by theexecutemethod.factory- thePinnedThreadfactory 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-threadExecutorServiceinception.- Parameters:
factory- thePinnedThreadFactoryused create affinity awarePinnedThreadinstances- 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-sizeExecutorServiceinception.- Parameters:
size- number ofPinnedThreadinstances to maintain in the poolfactory- thePinnedThreadFactoryused create affinity awarePinnedThreadinstances- Returns:
- the affinity aware
ExecutorService
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-