Executor, ExecutorServicepublic class ScalingThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor that actively increases the number of threads when new tasks come in,
instead of waiting for the task queue to fill up.
see https://github.com/kimchy/kimchy.github.com/blob/master/_posts/2008-11-23-juc-executorservice-gotcha.textileThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor | Description |
|---|---|
ScalingThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue) |
|
ScalingThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory factory) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
|
protected void |
beforeExecute(Thread t,
Runnable r) |
|
int |
getActiveCount() |
|
static ExecutorService |
newScalingThreadPool(int min,
int max,
long keepAliveTime) |
|
static ExecutorService |
newScalingThreadPool(int min,
int max,
long keepAliveTime,
ThreadFactory factory) |
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitallowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, finalize, 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, toStringpublic ScalingThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
public ScalingThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory factory)
public static ExecutorService newScalingThreadPool(int min, int max, long keepAliveTime)
public static ExecutorService newScalingThreadPool(int min, int max, long keepAliveTime, ThreadFactory factory)
public int getActiveCount()
getActiveCount in class ThreadPoolExecutorprotected void beforeExecute(Thread t, Runnable r)
beforeExecute in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorCopyright © 2017–2019. All rights reserved.