public final class ThreadQueue
extends java.lang.Object
Tasks added
with the enqueue(Task) method. The number of threads managed by this
queue is never less than getMinThreads() nor more than
getMaxThreads().| Modifier and Type | Class and Description |
|---|---|
protected class |
ThreadQueue.QueueExecutor
Executes
Tasks added to the queue. |
| Constructor and Description |
|---|
ThreadQueue() |
ThreadQueue(int minThreads,
int maxThreads,
boolean daemonThreads,
long shrinkTimeout,
TaskFailureHandler failureHandler) |
ThreadQueue(int minThreads,
int maxThreads,
boolean daemonThreads,
long shrinkTimeout,
TaskFailureHandler failureHandler,
java.lang.String threadGroupId) |
| Modifier and Type | Method and Description |
|---|---|
void |
enqueue(Task task)
Enqueue the specified task.
|
int |
getActiveThreadCount() |
int |
getMaxThreads() |
int |
getMinThreads() |
int |
getPosition(Task task) |
int |
getWaitingThreadCount()
Returns the number of waiting threads.
|
protected void |
handleFailure(Task task)
Handle a failed execution by delegating to the assigned
TaskFailureHandler. |
boolean |
isDaemonThreads() |
boolean |
isStarted()
Returns whether the queue has been started
|
boolean |
isStopped()
Returns whether the queue has been stopped, in which case all threads
will be stopped.
|
protected Task |
next()
Returns the next task ro be executed.
|
protected java.lang.String |
paramString() |
void |
start()
Start the thread queue.
|
void |
stop() |
java.lang.String |
toString() |
public ThreadQueue()
public ThreadQueue(int minThreads,
int maxThreads,
boolean daemonThreads,
long shrinkTimeout,
TaskFailureHandler failureHandler)
public ThreadQueue(int minThreads,
int maxThreads,
boolean daemonThreads,
long shrinkTimeout,
TaskFailureHandler failureHandler,
java.lang.String threadGroupId)
minThreads - maxThreads - daemonThreads - shrinkTimeout - failureHandler - threadGroupId - public int getMinThreads()
public int getMaxThreads()
public boolean isDaemonThreads()
public int getActiveThreadCount()
public int getWaitingThreadCount()
public boolean isStarted()
public boolean isStopped()
public void stop()
public void start()
minThreads property.public int getPosition(Task task)
task - The task to get the position for.public void enqueue(Task task)
task - The task to enqueue.java.lang.IllegalStateException - If the task already has been added to this
or another thread queue or if the task has been canceled already.protected Task next() throws java.lang.InterruptedException
java.lang.InterruptedExceptionprotected void handleFailure(Task task)
TaskFailureHandler.protected java.lang.String paramString()
public java.lang.String toString()
toString in class java.lang.ObjectCopyright ? Technia AB. All Rights Reserved.