public abstract class SystemThreadTask extends Object implements CallBack
To use it you simply override doTask(). This method will get called in the System Message Thread when the execute() method of the SystemThreadTask is executed.
If execute() is called when the system is already in the System Thread, then the doTask() method is called immediately. Otherwise, the current Thread is halted and a CallBack is requested, which will then execute doTask(). After doTask() has been executed the current Thread continues and returns the value returned by doTask().
Modifier and Type | Field and Description |
---|---|
int |
timeout
This is the number of milliseconds to wait before the callBack() completes.
|
Constructor and Description |
---|
SystemThreadTask() |
Modifier and Type | Method and Description |
---|---|
void |
callBack(Object data) |
protected abstract boolean |
doTask(Object data)
This is the only thing to override.
|
boolean |
execute(Object data)
Execute the doTask() method in a System Thread.
|
boolean |
execute(Object data,
boolean alwaysExecuteNow)
Execute the doTask() method in a System Thread or in the current thread - depending on the value
of alwaysExecuteNow.
|
public int timeout
protected abstract boolean doTask(Object data)
public final boolean execute(Object data)
data
- The data to be passed to doTask().public final boolean execute(Object data, boolean alwaysExecuteNow) throws InterruptedException
data
- The data to be passed to doTask().alwaysExecuteNow
- If this is true then doTask() will always be executed in the current thread.InterruptedException
- if the Thread was interrupted while
waiting for the task to complete in the System Thread.