|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.hawaii.ics.yucheng.BackgroundWorker<TResult,TProgress>
abstract class BackgroundWorker<TResult,TProgress>
An abstract class that provides the base functionality for background worker threads. This class works with the AWT event queue to transfer messages to and from the GUI and worker thread. This class is generic and supports any kind of progress message or result.
Nested Class Summary | |
---|---|
(package private) class |
BackgroundWorker.Delegate
A delegate class used to transfer messages between the GUI thread and the background worker thread. |
Field Summary | |
---|---|
private static int |
ACTION_ERROR
|
private static int |
ACTION_PROGRESS
|
private static int |
ACTION_RESULT
|
private static int |
ACTION_START
|
private boolean |
myCancelFlag
|
private java.lang.Thread |
myThread
|
Constructor Summary | |
---|---|
BackgroundWorker()
|
Method Summary | |
---|---|
void |
cancel()
Requests that the background worker should cancel. |
boolean |
isCancelled()
This method returns true if the GUI thread has requested that the background worker thread should cancel gracefully. |
boolean |
isRunning()
Returns true if the background worker is running and false otherwise. |
void |
join()
Joins the current thread with the worker thread. |
(package private) void |
processDelegate(BackgroundWorker.Delegate delegate)
Processes the delegate action. |
protected void |
processError(java.lang.Exception exception)
When overridden by a derived class, this method processes an error thrown from the background worker thread. |
protected void |
processProgress(TProgress progress)
When overridden by a derived class, this method processes a progress message sent by the background worker thread. |
protected void |
processResult(TResult result)
When overridden by a derived class, this method processes a result returned from the background worker thread. |
protected abstract TResult |
run()
This method runs from a background thread after the start() method has been called. |
protected void |
sendProgress(TProgress progress)
Sends a progress message from the background worker thread to the GUI thread. |
void |
start()
This method starts the background worker thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int ACTION_ERROR
private static final int ACTION_PROGRESS
private static final int ACTION_RESULT
private static final int ACTION_START
private boolean myCancelFlag
private java.lang.Thread myThread
Constructor Detail |
---|
BackgroundWorker()
Method Detail |
---|
public void cancel()
public boolean isCancelled()
public boolean isRunning()
public void join() throws java.lang.InterruptedException
java.lang.InterruptedException
- Thrown if any thread has interrupted the
current thread. The interrupted status of the current thread is
cleared when this exception is thrown.void processDelegate(BackgroundWorker.Delegate delegate)
delegate
- The delegate that is running.protected void processError(java.lang.Exception exception)
exception
- The error thrown by the background worker thread.protected void processProgress(TProgress progress)
progress
- The progress data.protected void processResult(TResult result)
result
- The result from the background worker thread.protected abstract TResult run() throws java.lang.Exception
java.lang.Exception
- Thrown if any kind of exception occurs during execution.protected void sendProgress(TProgress progress)
progress
- The progress message.public void start()
java.lang.IllegalStateException
- Thrown if the thread has already started.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |