org.uacalc.ui.tm
Class BackgroundTask<V>
java.lang.Object
org.uacalc.ui.tm.BackgroundTask<V>
- All Implemented Interfaces:
- java.lang.Runnable, java.util.concurrent.Future<V>
public abstract class BackgroundTask<V>
- extends java.lang.Object
- implements java.lang.Runnable, java.util.concurrent.Future<V>
BackgroundTask
Background task class supporting cancellation, completion notification,
and progress notification.
- Author:
- Brian Goetz and Tim Peierls
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
status
protected volatile BackgroundTask.Status status
report
protected ProgressReport report
BackgroundTask
public BackgroundTask(ProgressReport report)
setProgressReport
protected void setProgressReport(ProgressReport pr)
getProgressReport
public ProgressReport getProgressReport()
compute
protected abstract V compute()
throws java.lang.Exception
- Throws:
java.lang.Exception
onCompletion
protected void onCompletion(V result,
java.lang.Throwable exception,
boolean cancelled,
boolean outOfMemory)
getStatus
public BackgroundTask.Status getStatus()
setStatus
public void setStatus(BackgroundTask.Status v)
onProgress
protected void onProgress(int current,
int max)
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel in interface java.util.concurrent.Future<V>
get
public V get()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
- Specified by:
get in interface java.util.concurrent.Future<V>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
get
public V get(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
- Specified by:
get in interface java.util.concurrent.Future<V>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled in interface java.util.concurrent.Future<V>
isDone
public boolean isDone()
- Specified by:
isDone in interface java.util.concurrent.Future<V>
run
public void run()
- Specified by:
run in interface java.lang.Runnable
Copyright 2003 Ralph Freese. All Rights Reserved.