ewe.sys
Class ThreadTask

java.lang.Object
  extended byewe.sys.ThreadTask
All Implemented Interfaces:
Runnable

public abstract class ThreadTask
extends Object
implements Runnable


Field Summary
 boolean complete
          This is set true when doTask() has returned.
 Throwable exception
          This is set to any exception thrown when run in a separate mThread.
 
Constructor Summary
ThreadTask()
           
 
Method Summary
protected abstract  void doTask(boolean runningInSeparateThread, Object data, Wrapper returnValue)
          You must override this method.
 Wrapper execute(Object data)
          This attempts to execute the task.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

complete

public boolean complete
This is set true when doTask() has returned.


exception

public Throwable exception
This is set to any exception thrown when run in a separate mThread.

Constructor Detail

ThreadTask

public ThreadTask()
Method Detail

doTask

protected abstract void doTask(boolean runningInSeparateThread,
                               Object data,
                               Wrapper returnValue)
You must override this method. If the task should return a value it should call one of the setXXX() methods in the returnValue wrapper.


run

public final void run()
Specified by:
run in interface Runnable

execute

public Wrapper execute(Object data)
This attempts to execute the task. If the current thread is an mThread then it will call doTask() directly and return the Wrapper that will hold the return value of the task.

If the current Thread is not an mThread, then it will create a new mThread which will then call doTask() - and this method will return null.

Parameters:
data - optional data to send to the task.
Returns:
A Wrapper holding the return value from doTask() or null if the task was postponed to be run in an mThread.