|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.concurrent.AbstractExecutorService
org.jboss.threads.QueueExecutor
public final class QueueExecutor
An executor which uses a regular queue to hold tasks. The executor may be tuned at runtime in many ways.
Constructor Summary | |
---|---|
QueueExecutor(int coreThreads,
int maxThreads,
long keepAliveTime,
TimeUnit keepAliveTimeUnit,
int queueLength,
ThreadFactory threadFactory,
boolean blocking,
Executor handoffExecutor)
Create a new instance. |
|
QueueExecutor(int coreThreads,
int maxThreads,
long keepAliveTime,
TimeUnit keepAliveTimeUnit,
Queue<Runnable> queue,
ThreadFactory threadFactory,
boolean blocking,
Executor handoffExecutor)
Create a new instance. |
|
QueueExecutor(int coreThreads,
int maxThreads,
long keepAliveTime,
TimeUnit keepAliveTimeUnit,
Queue<Runnable> queue,
ThreadFactory threadFactory,
boolean blocking,
Executor handoffExecutor,
DirectExecutor taskExecutor)
Create a new instance. |
Method Summary | ||
---|---|---|
|
addShutdownListener(EventListener<A> shutdownListener,
A attachment)
Add a shutdown listener. |
|
boolean |
awaitTermination(long timeout,
TimeUnit unit)
|
|
void |
execute(Runnable task)
Execute a task. |
|
void |
executeBlocking(Runnable task)
Execute a task, blocking until it can be accepted, or until the calling thread is interrupted. |
|
void |
executeBlocking(Runnable task,
long timeout,
TimeUnit unit)
Execute a task, blocking until it can be accepted, a timeout elapses, or the calling thread is interrupted. |
|
void |
executeNonBlocking(Runnable task)
Execute a task, without blocking. |
|
int |
getCoreThreads()
|
|
int |
getCurrentThreadCount()
|
|
Executor |
getHandoffExecutor()
Get the handoff executor which is called when a task cannot be accepted immediately. |
|
long |
getKeepAliveTime()
|
|
int |
getLargestThreadCount()
|
|
int |
getMaxThreads()
|
|
int |
getRejectedCount()
|
|
boolean |
isAllowCoreThreadTimeout()
|
|
boolean |
isBlocking()
Determine whether this thread pool executor is set to block when a task cannot be accepted immediately. |
|
boolean |
isShutdown()
|
|
boolean |
isTerminated()
|
|
void |
setAllowCoreThreadTimeout(boolean allowCoreThreadTimeout)
|
|
void |
setBlocking(boolean blocking)
Set whether this thread pool executor should be set to block when a task cannot be accepted immediately. |
|
void |
setCoreThreads(int coreThreads)
|
|
void |
setHandoffExecutor(Executor handoffExecutor)
Set the handoff executor which is called when a task cannot be accepted immediately. |
|
void |
setKeepAliveTime(long milliseconds)
|
|
void |
setKeepAliveTime(long keepAliveTime,
TimeUnit keepAliveTimeUnit)
Set the keep-alive time to the given amount of time. |
|
void |
setMaxThreads(int maxThreads)
|
|
void |
shutdown()
|
|
List<Runnable> |
shutdownNow()
|
Methods inherited from class java.util.concurrent.AbstractExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.concurrent.ExecutorService |
---|
invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit |
Constructor Detail |
---|
public QueueExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit keepAliveTimeUnit, Queue<Runnable> queue, ThreadFactory threadFactory, boolean blocking, Executor handoffExecutor, DirectExecutor taskExecutor)
coreThreads
- the number of threads to create before enqueueing tasksmaxThreads
- the maximum number of threads to createkeepAliveTime
- the amount of time that an idle thread should remain activekeepAliveTimeUnit
- the unit of time for keepAliveTime
queue
- the queue to use for tasksthreadFactory
- the thread factory to use for new threadsblocking
- true
if the executor should block when the queue is full and no threads are available, false
to use the handoff executorhandoffExecutor
- the executor which is called when blocking is disabled and a task cannot be accepted, or null
to reject the tasktaskExecutor
- the executor to use to execute taskspublic QueueExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit keepAliveTimeUnit, Queue<Runnable> queue, ThreadFactory threadFactory, boolean blocking, Executor handoffExecutor)
coreThreads
- the number of threads to create before enqueueing tasksmaxThreads
- the maximum number of threads to createkeepAliveTime
- the amount of time that an idle thread should remain activekeepAliveTimeUnit
- the unit of time for keepAliveTime
queue
- the queue to use for tasksthreadFactory
- the thread factory to use for new threadsblocking
- true
if the executor should block when the queue is full and no threads are available, false
to use the handoff executorhandoffExecutor
- the executor which is called when blocking is disabled and a task cannot be accepted, or null
to reject the taskpublic QueueExecutor(int coreThreads, int maxThreads, long keepAliveTime, TimeUnit keepAliveTimeUnit, int queueLength, ThreadFactory threadFactory, boolean blocking, Executor handoffExecutor)
coreThreads
- the number of threads to create before enqueueing tasksmaxThreads
- the maximum number of threads to createkeepAliveTime
- the amount of time that an idle thread should remain activekeepAliveTimeUnit
- the unit of time for keepAliveTime
queueLength
- the fixed queue length to use for tasksthreadFactory
- the thread factory to use for new threadsblocking
- true
if the executor should block when the queue is full and no threads are available, false
to use the handoff executorhandoffExecutor
- the executor which is called when blocking is disabled and a task cannot be accepted, or null
to reject the taskMethod Detail |
---|
public void execute(Runnable task) throws RejectedExecutionException
execute
in interface Executor
execute
in interface BlockingExecutor
task
- the task to execute
RejectedExecutionException
- when a task is rejected by the handoff executor
StoppedExecutorException
- when the executor is terminating
ExecutionInterruptedException
- when blocking is enabled and the current thread is interrupted before a task could be acceptedpublic void executeBlocking(Runnable task) throws RejectedExecutionException, InterruptedException
executeBlocking
in interface BlockingExecutor
task
- the task to submit
StoppedExecutorException
- if the executor was shut down before the task was accepted
ThreadCreationException
- if a thread could not be created for some reason
RejectedExecutionException
- if execution is rejected for some other reason
InterruptedException
- if the current thread was interrupted before the task could be accepted
NullPointerException
- if command is null
public void executeBlocking(Runnable task, long timeout, TimeUnit unit) throws RejectedExecutionException, InterruptedException
executeBlocking
in interface BlockingExecutor
task
- the task to submittimeout
- the amount of time to waitunit
- the unit of time
ExecutionTimedOutException
- if the timeout elapsed before a task could be accepted
StoppedExecutorException
- if the executor was shut down before the task was accepted
ThreadCreationException
- if a thread could not be created for some reason
RejectedExecutionException
- if execution is rejected for some other reason
InterruptedException
- if the current thread was interrupted before the task could be accepted
NullPointerException
- if command is null
public void executeNonBlocking(Runnable task) throws RejectedExecutionException
executeNonBlocking
in interface BlockingExecutor
task
- the task to submit
StoppedExecutorException
- if the executor was shut down before the task was accepted
ThreadCreationException
- if a thread could not be created for some reason
RejectedExecutionException
- if execution is rejected for some other reason
NullPointerException
- if command is null
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
public boolean isAllowCoreThreadTimeout()
isAllowCoreThreadTimeout
in interface BoundedQueueThreadPoolExecutorMBean
public void setAllowCoreThreadTimeout(boolean allowCoreThreadTimeout)
setAllowCoreThreadTimeout
in interface BoundedQueueThreadPoolExecutorMBean
public int getCoreThreads()
getCoreThreads
in interface BoundedQueueThreadPoolExecutorMBean
public void setCoreThreads(int coreThreads)
setCoreThreads
in interface BoundedQueueThreadPoolExecutorMBean
public int getMaxThreads()
getMaxThreads
in interface ThreadPoolExecutorMBean
public void setMaxThreads(int maxThreads)
setMaxThreads
in interface ThreadPoolExecutorMBean
public long getKeepAliveTime()
getKeepAliveTime
in interface ThreadPoolExecutorMBean
public void setKeepAliveTime(long keepAliveTime, TimeUnit keepAliveTimeUnit)
keepAliveTime
- the amount of timekeepAliveTimeUnit
- the unit of timepublic void setKeepAliveTime(long milliseconds)
setKeepAliveTime
in interface ThreadPoolExecutorMBean
public boolean isBlocking()
isBlocking
in interface BoundedThreadPoolExecutorMBean
true
if blocking is enabled, false
if the handoff executor is usedpublic void setBlocking(boolean blocking)
setBlocking
in interface BoundedThreadPoolExecutorMBean
blocking
- true
if blocking is enabled, false
if the handoff executor is usedpublic Executor getHandoffExecutor()
public void setHandoffExecutor(Executor handoffExecutor)
handoffExecutor
- the handoff executorpublic <A> void addShutdownListener(EventListener<A> shutdownListener, A attachment)
addShutdownListener
in interface ShutdownListenable
A
- the attachment typeshutdownListener
- the listenerattachment
- the attachment value to pass to the listenerpublic int getCurrentThreadCount()
getCurrentThreadCount
in interface ThreadExecutorMBean
public int getLargestThreadCount()
getLargestThreadCount
in interface ThreadExecutorMBean
public int getRejectedCount()
getRejectedCount
in interface ThreadExecutorMBean
|
JBoss Threads 2.0.0.GA-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |