class ThreadFactoryExecutor extends java.lang.Object implements BlockingExecutor, BoundedThreadPoolExecutorMBean
| Modifier and Type | Field and Description |
|---|---|
private boolean |
blocking |
private int |
currentThreadCount |
private java.util.concurrent.ThreadFactory |
factory |
private int |
largestThreadCount |
private java.util.concurrent.Semaphore |
limitSemaphore |
private java.lang.Object |
lock |
private int |
maxThreads |
private java.util.concurrent.atomic.AtomicInteger |
rejected |
private DirectExecutor |
taskExecutor |
| Constructor and Description |
|---|
ThreadFactoryExecutor(java.util.concurrent.ThreadFactory factory,
int maxThreads,
boolean blocking,
DirectExecutor taskExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute(java.lang.Runnable task)
Executes the given command at some time in the future.
|
void |
executeBlocking(java.lang.Runnable task)
Execute a task, blocking until it can be accepted, or until the calling thread is interrupted.
|
void |
executeBlocking(java.lang.Runnable task,
long timeout,
java.util.concurrent.TimeUnit unit)
Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted.
|
void |
executeNonBlocking(java.lang.Runnable task)
Execute a task, without blocking.
|
int |
getCurrentThreadCount() |
long |
getKeepAliveTime() |
int |
getLargestThreadCount() |
int |
getMaxThreads() |
int |
getQueueSize() |
int |
getRejectedCount() |
boolean |
isBlocking() |
void |
setBlocking(boolean blocking) |
void |
setKeepAliveTime(long milliseconds) |
void |
setMaxThreads(int maxThreads) |
java.lang.String |
toString() |
private final java.util.concurrent.ThreadFactory factory
private final java.util.concurrent.Semaphore limitSemaphore
private final DirectExecutor taskExecutor
private final java.lang.Object lock
private int maxThreads
private int largestThreadCount
private int currentThreadCount
private final java.util.concurrent.atomic.AtomicInteger rejected
private volatile boolean blocking
ThreadFactoryExecutor(java.util.concurrent.ThreadFactory factory,
int maxThreads,
boolean blocking,
DirectExecutor taskExecutor)
public int getMaxThreads()
getMaxThreads in interface ThreadPoolExecutorMBeanpublic void setMaxThreads(int maxThreads)
setMaxThreads in interface ThreadPoolExecutorMBeanpublic void execute(java.lang.Runnable task)
BlockingExecutorexecute in interface java.util.concurrent.Executorexecute in interface BlockingExecutortask - the task to submitpublic void executeBlocking(java.lang.Runnable task)
throws java.util.concurrent.RejectedExecutionException,
java.lang.InterruptedException
BlockingExecutorexecuteBlocking in interface BlockingExecutortask - the task to submitStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonjava.lang.InterruptedException - if the current thread was interrupted before the task could be acceptedpublic void executeBlocking(java.lang.Runnable task,
long timeout,
java.util.concurrent.TimeUnit unit)
throws java.util.concurrent.RejectedExecutionException,
java.lang.InterruptedException
BlockingExecutorexecuteBlocking in interface BlockingExecutortask - the task to submittimeout - the amount of time to waitunit - the unit of timeExecutionTimedOutException - if the timeout elapsed before a task could be acceptedStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonjava.lang.InterruptedException - if the current thread was interrupted before the task could be acceptedpublic void executeNonBlocking(java.lang.Runnable task)
throws java.util.concurrent.RejectedExecutionException
BlockingExecutorexecuteNonBlocking in interface BlockingExecutortask - the task to submitStoppedExecutorException - if the executor was shut down before the task was acceptedThreadCreationException - if a thread could not be created for some reasonjava.util.concurrent.RejectedExecutionException - if execution is rejected for some other reasonpublic boolean isBlocking()
isBlocking in interface BoundedThreadPoolExecutorMBeanpublic void setBlocking(boolean blocking)
setBlocking in interface BoundedThreadPoolExecutorMBeanpublic int getLargestThreadCount()
getLargestThreadCount in interface ThreadExecutorMBeanpublic int getCurrentThreadCount()
getCurrentThreadCount in interface ThreadExecutorMBeanpublic int getQueueSize()
getQueueSize in interface ThreadExecutorMBeanpublic int getRejectedCount()
getRejectedCount in interface ThreadExecutorMBeanpublic long getKeepAliveTime()
getKeepAliveTime in interface ThreadPoolExecutorMBeanpublic void setKeepAliveTime(long milliseconds)
setKeepAliveTime in interface ThreadPoolExecutorMBeanpublic java.lang.String toString()
toString in class java.lang.Object