public class RuntimeThreadPoolExecutor
extends java.util.concurrent.AbstractExecutorService
ThreadPoolExecutor. This executor records processing statistics as well as monitors for stalled threads. When a
stalled thread is encountered (i.e. when the processing time for a runnable has exceeded a threshold), an event is sent to the monitor.
The default configuration uses a bounded queue to accept work. If the queue size is exceeded, work will be rejected. This allows the runtime to degrade
gracefully under load by pushing requests back to the client and avoid out-of-memory conditions.| Constructor and Description |
|---|
RuntimeThreadPoolExecutor(ExecutorMonitor monitor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
execute(java.lang.Runnable runnable) |
int |
getActiveCount() |
long |
getCompletedWorkCount() |
int |
getCorePoolSize() |
int |
getCount() |
long |
getKeepAliveTime() |
int |
getLargestPoolSize() |
long |
getLongestRunning() |
int |
getMaximumPoolSize() |
double |
getMeanExecutionTime() |
int |
getRemainingCapacity() |
int |
getStallThreshold() |
long |
getTotalExecutionTime() |
void |
init() |
boolean |
isAllowCoreThreadTimeOut() |
boolean |
isCheckStalledThreads() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) |
void |
setCheckStalledThreads(boolean checkStalledThreads) |
void |
setCorePoolSize(int size) |
void |
setCoreSize(int size)
Sets the number of threads always available to service the executor queue.
|
void |
setKeepAliveTime(long keepAliveTime) |
void |
setMaximumPoolSize(int size) |
void |
setMaximumSize(int size)
Sets the maximum number of threads to service the executor queue.
|
void |
setQueueSize(int size)
Sets the maximum number of work items that can be queued before the executor rejects additional work.
|
void |
setRejectedExecutionHandler(java.lang.String handler) |
void |
setStallCheckPeriod(long period)
Sets the period between checks for stalled threads.
|
void |
setStallThreshold(int stallThreshold)
Sets the time a thread can be processing work before it is considered stalled.
|
void |
setStatisticsOff(boolean statisticsOff) |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
void |
stop() |
public RuntimeThreadPoolExecutor(ExecutorMonitor monitor)
public void setCoreSize(int size)
size - the number of threads.public void setMaximumSize(int size)
size - the number of threads.public void setQueueSize(int size)
size - the maximum number of work itemspublic void setStallCheckPeriod(long period)
period - the period between checks for stalled threads.public void setRejectedExecutionHandler(java.lang.String handler)
public void setStallThreshold(int stallThreshold)
stallThreshold - the time a thread can be processing work before it is considered stalledpublic long getKeepAliveTime()
public void setKeepAliveTime(long keepAliveTime)
public boolean isAllowCoreThreadTimeOut()
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut)
public boolean isCheckStalledThreads()
public void setCheckStalledThreads(boolean checkStalledThreads)
public void setStatisticsOff(boolean statisticsOff)
public int getStallThreshold()
public int getActiveCount()
public int getMaximumPoolSize()
public void setMaximumPoolSize(int size)
public int getCorePoolSize()
public void setCorePoolSize(int size)
public int getLargestPoolSize()
public int getRemainingCapacity()
public long getTotalExecutionTime()
public long getCompletedWorkCount()
public double getMeanExecutionTime()
public long getLongestRunning()
public int getCount()
public void init()
public void stop()
public void execute(java.lang.Runnable runnable)
public void shutdown()
public java.util.List<java.lang.Runnable> shutdownNow()
public boolean isShutdown()
public boolean isTerminated()
public boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
java.lang.InterruptedException