public class SingleWorkerThread extends AbstractWorkerThread implements java.lang.Runnable
WorkerThread that uses a single worker thread to run
Tasks subclasses. | Modifier and Type | Class and Description |
|---|---|
private static class |
SingleWorkerThread.Link |
| Modifier and Type | Field and Description |
|---|---|
private SingleWorkerThread.Link |
current |
(package private) static boolean |
debug |
private boolean |
pending |
private static int |
sequence |
private java.lang.Thread |
thread |
| Constructor and Description |
|---|
SingleWorkerThread() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getThreadName()
Returns the name of the worker thread used by this WorkerThread.
|
(package private) boolean |
hasPendingTasks() |
private boolean |
hasTasks() |
boolean |
isAlive()
Returns whether this WorkerThread is alive.
|
protected boolean |
isThreadInterrupted()
Returns whether the worker thread has been interrupted or not.
|
boolean |
isWorkerThread()
Returns whether the current thread is a thread used by the implementation of
this WorkerThread to run
Tasks. |
(package private) static int |
nextSequence() |
void |
postTask(Task t)
Posts the given Task onto an internal queue.
|
void |
run()
The worker thread dequeues one
Task from the internal queue via takeTask()
and then executes it. |
protected void |
run(Task task)
Executes the given
Task. |
void |
start()
Starts this WorkerThread, responsible for running
Tasks (not in the
Event Dispatch Thread). |
protected void |
stop()
Stops abruptly this WorkerThread.
|
protected Task |
takeTask()
Removes and returns the first available
Task from the internal queue. |
runTaskprivate static int sequence
static final boolean debug
private java.lang.Thread thread
private SingleWorkerThread.Link current
private boolean pending
public void start()
WorkerThreadTasks (not in the
Event Dispatch Thread).
Applets can stop threads used by implementations of this WorkerThread in any moment,
and this method also can be used to restart this WorkerThread
if it results that it is not alive anymore.start in interface WorkerThreadWorkerThread.isAlive()protected java.lang.String getThreadName()
static int nextSequence()
protected void stop()
public boolean isAlive()
WorkerThreadisAlive in interface WorkerThreadWorkerThread.start()public boolean isWorkerThread()
WorkerThreadTasks.isWorkerThread in interface WorkerThreadpublic void postTask(Task t)
postTask in interface WorkerThreadtakeTask()protected Task takeTask() throws java.lang.InterruptedException
Task from the internal queue.
If no Tasks are available, this method blocks until a Task is posted via
postTask(foxtrot.Task)java.lang.InterruptedExceptionprivate boolean hasTasks()
boolean hasPendingTasks()
protected boolean isThreadInterrupted()
Thread.isInterrupted()public void run()
Task from the internal queue via takeTask()
and then executes it.run in interface java.lang.Runnableprotected void run(Task task)
Task.
This implementation will just call AbstractWorkerThread.runTask(foxtrot.Task).