public class SingleWorkerThread extends AbstractWorkerThread implements Runnable
WorkerThread that uses a single worker thread to run
Tasks subclasses. | Constructor and Description |
|---|
SingleWorkerThread() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getThreadName()
Returns the name of the worker thread used by this WorkerThread.
|
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. |
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. |
runTaskpublic 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 String getThreadName()
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 InterruptedException
Task from the internal queue.
If no Tasks are available, this method blocks until a Task is posted via
postTask(foxtrot.Task)InterruptedExceptionprotected boolean isThreadInterrupted()
Thread.isInterrupted()public void run()
Task from the internal queue via takeTask()
and then executes it.protected void run(Task task)
Task.
This implementation will just call AbstractWorkerThread.runTask(foxtrot.Task).Copyright © 2002-2011. All Rights Reserved.