org.fife.ui
Class GUIWorkerThread

java.lang.Object
  extended by org.fife.ui.GUIWorkerThread

public abstract class GUIWorkerThread
extends java.lang.Object

This is a helper class that will do non-GUI-related work in a separate, dedicated thread, to keep the GUI responsive while doing CPU-heavy tasks.

This class is a direct ripoff of SwingWorker 3.


Constructor Summary
GUIWorkerThread()
          Start a thread that will call the construct method and then exit.
 
Method Summary
abstract  java.lang.Object construct()
          Compute the value to be returned by the get method.
 void finished()
          Called on the event dispatching thread (not on the worker thread) after the construct method has returned.
 java.lang.Object get()
          Return the value created by the construct method.
protected  java.lang.Object getValue()
          Get the value produced by the worker thread, or null if it hasn't been constructed yet.
 void interrupt()
          Call this method to force the worker to stop what it's doing.
 void reset()
          "Resets" this class so its start method can be called a second time.
 void start()
          Start the worker thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GUIWorkerThread

public GUIWorkerThread()
Start a thread that will call the construct method and then exit. You need to call the start method on this newly-created worker thread next.

Method Detail

construct

public abstract java.lang.Object construct()
Compute the value to be returned by the get method. This method should be overridden to do all the CPU-intensive stuff that you don't want to do in the event dispatch thread.


finished

public void finished()
Called on the event dispatching thread (not on the worker thread) after the construct method has returned.

This method should be overridden to do any work with the value returned from get to prevent deadlock.


get

public java.lang.Object get()
Return the value created by the construct method. Returns null if either the constructing thread or the current thread was interrupted before a value was produced. Note that this method could cause deadlock if it is called outside of the finished method.

Returns:
The value created by the construct method.

getValue

protected java.lang.Object getValue()
Get the value produced by the worker thread, or null if it hasn't been constructed yet.


interrupt

public void interrupt()
Call this method to force the worker to stop what it's doing.


reset

public void reset()
"Resets" this class so its start method can be called a second time. If this thread completes (either normally or after you call interrupt on it), you must call this method before calling start again.


start

public void start()
Start the worker thread.