public abstract class Task extends Object
run() method with the time-consuming code, and not worry about
exceptions, for example:
Task task = new Task()
{
public Object run() throws InterruptedException
{
Thread.sleep(10000);
return null;
}
};
Exceptions and Errors thrown by the run() method will be rethrown automatically by
Worker.post(Task) or by ConcurrentWorker.post(Task)Worker,
ConcurrentWorker| Modifier | Constructor and Description |
|---|---|
protected |
Task()
Creates a new Task.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
getResultOrThrow()
Returns the result of this Task operation, as set by
setResult(java.lang.Object). |
boolean |
isCompleted()
Returns whether the execution of this Task has been completed or not.
|
abstract Object |
run()
The method to implement with time-consuming code.
|
public abstract Object run() throws Exception
Exceptionprotected final Object getResultOrThrow() throws Exception
setResult(java.lang.Object).
If an exception or an error is thrown by run(), it is rethrown here.
Synchronized since the variables are accessed from 2 threads
Accessed from the AWT Event Dispatch Thread.ExceptionsetResult(java.lang.Object),
setThrowable(java.lang.Throwable)public final boolean isCompleted()
Copyright © 2002-2011. All Rights Reserved.