Package org.alfresco.util
Class DynamicallySizedThreadPoolExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- org.alfresco.util.DynamicallySizedThreadPoolExecutor
-
- All Implemented Interfaces:
Executor,ExecutorService
public class DynamicallySizedThreadPoolExecutor extends ThreadPoolExecutor
This is an instance ofThreadPoolExecutorwhich behaves how one would expect it to, even when faced with an unlimited queue. Unlike the defaultThreadPoolExecutor, it will add new Threads up tomaximumPoolSizewhen there is lots of pending work, rather than only when the queue is full (which it often never will be, especially for unlimited queues)- Author:
- Nick Burch
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
-
Constructor Summary
Constructors Constructor Description DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafterExecute(Runnable r, Throwable t)voidexecute(Runnable command)voidsetCorePoolSize(int corePoolSize)-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, 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
-
-
-
-
Constructor Detail
-
DynamicallySizedThreadPoolExecutor
public DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
-
DynamicallySizedThreadPoolExecutor
public DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
DynamicallySizedThreadPoolExecutor
public DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
-
DynamicallySizedThreadPoolExecutor
public DynamicallySizedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
-
-
Method Detail
-
setCorePoolSize
public void setCorePoolSize(int corePoolSize)
- Overrides:
setCorePoolSizein classThreadPoolExecutor
-
execute
public void execute(Runnable command)
- Specified by:
executein interfaceExecutor- Overrides:
executein classThreadPoolExecutor
-
afterExecute
protected void afterExecute(Runnable r, Throwable t)
- Overrides:
afterExecutein classThreadPoolExecutor
-
-