public class PausableThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
PausableThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory)
Copy of one of the constructors in
ThreadPoolExecutor . |
Modifier and Type | Method and Description |
---|---|
protected void |
beforeExecute(Thread t,
Runnable r) |
int |
getNumActiveTasks() |
void |
pause()
Pause all threads from executing new tasks.
|
void |
resume()
Resume all threads to run new tasks.
|
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
public PausableThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
ThreadPoolExecutor
.corePoolSize
- the core pool sizemaximumPoolSize
- the maximum pool sizekeepAliveTime
- the keep alive timeunit
- the unitworkQueue
- the work queuethreadFactory
- the thread factorypublic int getNumActiveTasks()
public void pause()
public void resume()
protected void beforeExecute(Thread t, Runnable r)
beforeExecute
in class ThreadPoolExecutor
Copyright © 2023. All Rights Reserved.