public class G9Worker extends Object
The runnables are executed in a FIFO fashion.
| Modifier and Type | Method and Description |
|---|---|
void |
enqueue(Runnable task)
Puts a task on the queue.
|
static G9Worker |
enqueueTask(Object controller,
Runnable task)
Thread-safe enqueuing of task on a G9Worker.
|
static G9Worker |
getWorker(Object controller)
Returns an instance of G9Worker.
|
boolean |
isEmpty()
Returns true if this workers queue is empty
|
boolean |
isRunning()
Returns true if this worker is currently doing a task.
|
void |
relinquish()
Removes all tasks from the queue, and stops the worker.
|
boolean |
waitOnQueue()
Waits on all tasks in the queue to finish before returning.
|
public static G9Worker enqueueTask(Object controller, Runnable task)
controller - the controlling objecttask - the task to enqueuegetWorker(Object),
enqueue(Runnable)public static G9Worker getWorker(Object controller)
relinquish(). Failing to do so will result in a
memory leak.controller - the controller "owning" the workerenqueueTask(Object, Runnable)public boolean waitOnQueue()
false, otherwise, the method waits until all
task on the queue is finished and no current task is executed, and then
returns truetrue if all task are finishedpublic void enqueue(Runnable task)
task - the task that is put on the queue.enqueueTask(Object, Runnable)public void relinquish()
public boolean isRunning()
public boolean isEmpty()
Copyright © 2006–2020 Esito AS. All rights reserved.