EDU.oswego.cs.dl.util.concurrent
public class: QueuedExecutor [javadoc |
source]
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.ThreadFactoryUser
EDU.oswego.cs.dl.util.concurrent.QueuedExecutor
All Implemented Interfaces:
Executor
An implementation of Executor that queues incoming
requests until they can be processed by a single background
thread.
The thread is not actually started until the first
execute
request is encountered. Also, if the
thread is stopped for any reason (for example, after hitting
an unrecoverable exception in an executing task), one is started
upon encountering a new request, or if restart()
is
invoked.
Beware that, especially in situations
where command objects themselves invoke execute, queuing can
sometimes lead to lockups, since commands that might allow
other threads to terminate do not run at all when they are in the queue.
[ Introduction to this package. ]
Nested Class Summary: |
---|
protected class | QueuedExecutor.RunLoop | The runloop is isolated in its own Runnable class
just so that the main
class need not implement Runnable, which would
allow others to directly invoke run, which would
never make sense here. |
Field Summary |
---|
protected Thread | thread_ | The thread used to process commands |
protected static Runnable | ENDTASK | Special queue element to signal termination |
protected volatile boolean | shutdown_ | true if thread should shut down after processing current task |
protected final Channel | queue_ | The queue * |
protected final RunLoop | runLoop_ | |
Constructor: |
public QueuedExecutor() {
this(new BoundedLinkedQueue());
}
Construct a new QueuedExecutor that uses
a BoundedLinkedQueue with the current
DefaultChannelCapacity as its queue. |
public QueuedExecutor(Channel queue) {
queue_ = queue;
runLoop_ = new RunLoop();
}
Construct a new QueuedExecutor that uses
the supplied Channel as its queue.
This class does not support any methods that
reveal this queue. If you need to access it
independently (for example to invoke any
special status monitoring operations), you
should record a reference to it separately. |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |