public class ThreadPoolExecutor extends ThreadPoolExecutor
getSubmittedCount()
method, to be used to properly handle the work queue.
If a RejectedExecutionHandler is not specified a default one will be configured
and that one will always throw a RejectedExecutionExceptionThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
protected static StringManager |
sm
The string manager for this package.
|
Constructor and Description |
---|
ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue) |
ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler) |
ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory) |
ThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
void |
contextStopping() |
protected boolean |
currentThreadShouldBeStopped() |
void |
execute(Runnable command) |
void |
execute(Runnable command,
long timeout,
TimeUnit unit)
Executes the given command at some time in the future.
|
int |
getSubmittedCount() |
long |
getThreadRenewalDelay() |
void |
setThreadRenewalDelay(long threadRenewalDelay) |
protected void |
stopCurrentThreadIfNeeded()
If the current thread was started before the last time when a context was
stopped, an exception is thrown so that the current thread is stopped.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, 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
protected static final StringManager sm
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
public long getThreadRenewalDelay()
public void setThreadRenewalDelay(long threadRenewalDelay)
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor
protected void stopCurrentThreadIfNeeded()
protected boolean currentThreadShouldBeStopped()
public int getSubmittedCount()
public void execute(Runnable command)
execute
in interface Executor
execute
in class ThreadPoolExecutor
public void execute(Runnable command, long timeout, TimeUnit unit)
Executor
implementation.
If no threads are available, it will be added to the work queue.
If the work queue is full, the system will wait for the specified
time and it throw a RejectedExecutionException if the queue is still
full after that.command
- the runnable tasktimeout
- A timeout for the completion of the taskunit
- The timeout time unitRejectedExecutionException
- if this task cannot be
accepted for execution - the queue is fullNullPointerException
- if command or unit is nullpublic void contextStopping()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.