edu.wisc.ssec.mcidasv.util
Class BackgroundTask<V>
java.lang.Object
edu.wisc.ssec.mcidasv.util.BackgroundTask<V>
- All Implemented Interfaces:
- Runnable, Future<V>
- Direct Known Subclasses:
- Submitter
public abstract class BackgroundTask<V>
- extends Object
- implements Runnable, Future<V>
Background task class supporting cancellation, completion notification,
and progress notification. Courtesy of Java Concurrency in Practice,
written by Brian Goetz and Tim Peierls.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
computation
private final FutureTask<V> computation
BackgroundTask
public BackgroundTask()
setProgress
protected void setProgress(int current,
int max)
compute
protected abstract V compute()
throws Exception
- Throws:
Exception
onCompletion
protected void onCompletion(V result,
Throwable exception,
boolean cancelled)
onProgress
protected void onProgress(int current,
int max)
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interface Future<V>
get
public V get()
throws InterruptedException,
ExecutionException
- Specified by:
get
in interface Future<V>
- Throws:
InterruptedException
ExecutionException
get
public V get(long timeout,
TimeUnit unit)
throws InterruptedException,
ExecutionException,
TimeoutException
- Specified by:
get
in interface Future<V>
- Throws:
InterruptedException
ExecutionException
TimeoutException
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interface Future<V>
isDone
public boolean isDone()
- Specified by:
isDone
in interface Future<V>
run
public void run()
- Specified by:
run
in interface Runnable