public class EasyThread extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
EasyThread.ErrorListener<T>
Callback listener for errors on easy thread
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorListener(EasyThread.ErrorListener err)
Adds a callback for error events, notice that this code isn't thread
safe and should be invoked synchronously.
|
static void |
addGlobalErrorListener(EasyThread.ErrorListener err)
Adds a callback for error events, notice that this code isn't thread
safe and should be invoked synchronously.
|
boolean |
isThisIt()
Returns true if the current thread is the easy thread and false othewise similar
to the isEDT method
|
void |
kill()
Stops the thread once the current task completes
|
void |
removeErrorListener(EasyThread.ErrorListener err)
Removes a callback for error events, notice that this code isn't thread
safe and should be invoked synchronously.
|
static void |
removeGlobalErrorListener(EasyThread.ErrorListener err)
Removes a callback for error events, notice that this code isn't thread
safe and should be invoked synchronously.
|
void |
run(Runnable r)
Runs the given runnable on the thread, the method returns immediately
|
<T> void |
run(RunnableWithResult<T> r,
SuccessCallback<T> t)
Runs the given object asynchronously on the thread and returns the result object
|
<T> T |
run(RunnableWithResultSync<T> r)
Runs the given runnable on the thread and blocks until it completes, returns the value object
|
void |
runAndWait(Runnable r)
Invokes the given runnable on the thread and waits for its execution to complete
|
void |
setPriority(int newPriority)
Changes the priority of this EasyThread.
|
static EasyThread |
start(String name)
Starts a new thread
|
public static EasyThread start(String name)
name
- the display name for the threadpublic <T> void run(RunnableWithResult<T> r, SuccessCallback<T> t)
r
- runs this methodt
- object is passed to the success callbackpublic void run(Runnable r)
r
- the runnablepublic <T> T run(RunnableWithResultSync<T> r)
r
- the runnable with result that will execute on the threadpublic void runAndWait(Runnable r)
r
- the runnablepublic void kill()
public boolean isThisIt()
public void addErrorListener(EasyThread.ErrorListener err)
err
- the error callbackpublic void removeErrorListener(EasyThread.ErrorListener err)
err
- the error callbackpublic static void addGlobalErrorListener(EasyThread.ErrorListener err)
err
- the error callbackpublic static void removeGlobalErrorListener(EasyThread.ErrorListener err)
err
- the error callbackpublic final void setPriority(int newPriority)
newPriority
- priority to set this thread to