public abstract class AbstractTask<T> extends Thread implements Task<T>
Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected boolean |
canceled |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
AbstractTask() |
| Modifier and Type | Method and Description |
|---|---|
void |
background(TaskListener listener)
Run the task in a separate thread.
|
T |
call() |
void |
cancel()
Mark the task as canceled.
|
T |
getResult()
Retrieve the result of the task.
|
TaskStatus |
getStatus()
Retrieve the status of the task.
|
protected abstract T |
performTask()
Placeholder for the actual implementation.
|
void |
run() |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsetParameter, setParameters, setParametersprotected abstract T performTask() throws Exception
Exception - forwarded from the call() methodpublic T getResult()
Taskcall() to run and retrieve.public TaskStatus getStatus()
Taskpublic void cancel()
Taskpublic void background(TaskListener listener)
Taskbackground in interface Task<T>listener - will be notified when the task is doneCopyright © 2012–2020. All rights reserved.