wt.util
Class WTThread

java.lang.Object
  extended byjava.lang.Thread
      extended bywt.util.WTThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AdminAddHost.WaitForShow, AdminAddMount.WaitForShow, AdminAddSite.WaitForShow, AdminAddVault.WaitForShow, AdminEditFolder.WaitForShow, AdminEditVault.WaitForShow, AssociationsPanel.WorkThread, BaselineQueryListener.ProcessThread, BaselineQueryListener.QueryThread, BaselineTaskPanel.WorkThread, CalendarApplet.DelegateIndefinitelyThread, CalendarApplet.DelegateThread, CalendarApplet.InitializeThread, CalendarApplet.MarkNonWorkingThread, CalendarApplet.MarkWorkingThread, CalendarApplet.ResetAllThread, CalendarApplet.ResetThread, CheckOutTask.CheckOutThread, ChooseOccurrenceDialog.EventHandlerThread, ClassExplorer.WorkThread, ConfigSpecPanel.WorkThread, ContainerChooserDialog.WorkThread, CreateDocumentFrame.ActionThread, CreationClassDialog.InitializeClassesThread, CreationClassDialog.InitializeMultiListThread, DownloadFilesDialog.ActionThread, DownloadFilesDialog.DownloadContentThread, DuplicateConfigurationDialog.WorkThread, EditOccurrenceDialog.EventHandlerThread, EventThread, ExitAction.ActionThread, FileChooserDropApplet.WorkerThread, FileLocatorApplet.WorkerThread, FilePropertiesDialog.ActionThread, FileVaultTreeFrame.InitTreeViewThread, FindGroupPanel.WorkThread, FindOrgPanel.WorkThread, FindUserPanel.WorkThread, HelperPanel.WorkThread, HelperPanel.WorkThread, HTTPUploadDownloadTask.DownloadContentThread, HyperlinkFileChooserApplet.WorkerThread, IBADialog.WKThread, InitiateWorkflowApplet.WorkThread, JFileChooserApplet.WorkerThread, LifeCycleAdminApplet.WorkThread, LifeCycleDefinitionPanel.WorkThread, LifeCyclePanel.WorkThread, LifeCyclePanelWTUnit.WorkThread, NewAction.ActionThread, OccurrencesDialog.EventHandlerThread, OneOffDialog.WorkThread, OpenAction.ActionThread, OrgChooserDialog.WorkThread, PartExplorer.RefreshThread, PartExplorer.WorkThread, ParticipantSelectionDialog.WorkThread, PartTaskPanel.WkThread, ProcessEditor.CheckinThread, ProcessEditor.CheckoutThread, ProcessEditor.DeleteIterationThread, ProcessEditor.ExportThread, ProcessEditor.HistoryThread, ProcessEditor.ImportThread, ProcessEditor.InitializeThread, ProcessEditor.InitiateThread, ProcessEditor.NewThread, ProcessEditor.RenameThread, ProcessEditor.SaveAsThread, ProcessEditor.UndoCheckoutThread, ProcessEditor.UpdateThread, ProcessEditor.ViewThread, ProcessQuery, ProdMgmtApplet.WorkThread, ProjectAdminApplet.DeleteThread, ProjectAdminApplet.InitializeThread, ProjectAdminApplet.NewThread, ProjectAdminApplet.RenameThread, ProjectAdminApplet.SaveAsThread, ProjectAdminApplet.UpdateThread, ProjectAdminApplet.ViewThread, ProjectDefinitionFrame.WorkThread, ProjectPanel.WorkThread, QueryBuilderApplet.WorkThread, RapidFind.WorkThread, ReviseDialog.WorkThread, ReviseViewDialog.WorkThread, RoleHolderPanel.WorkThread, SaveAction.ActionThread, SaveAsAction.ActionThread, SaveAsDialog.WorkThread, SaveAsViewDialog.WorkThread, SelectFilesDialog.ActionThread, TransferProgressWatcher, UnitHelperPanel.WorkThread, UpdateDocumentFrame.ActionThread, UploadFilesDialog.ActionThread, UploadFilesDialog.UploadThread, UsageFrame.InitializeThread, UsesPanel.EventHandlerThread, ValidateAction.ActionThread, ValidateAllAction.ActionThread, VersionPanel.WorkThread, ViewDocumentFrame.ActionThread, ViewFolderDialog.InitPropertiesThread, WfContainerTemplatePanel.AddEditorThread, WfContainerTemplatePanel.AddLinkEditorThread, WfNodeTemplateEditor.RefreshThread, WfNodeTemplatePanel.InitializeThread, WindchillExplorerApplet.WorkThread, WindchillExplorerFrame.ExpandToFolderThread, WindchillExplorerFrame.InitCreateMenuThread, WindchillExplorerFrame.InitializeCabinetThread, WindchillExplorerFrame.InitializeExplorerThread, WindchillExplorerFrame.ShowCabinetsThread, WindchillExplorerFrame.WorkThread, WorkflowPanel.WorkThread, WTAttribute.WorkThread, WTContentHolder.ActionThread, WTExplorer.ProcessExpose

public class WTThread
extends Thread

A thread that is associated with a WTContext and supports property change events. This thread class is a Java Bean with bound properties for providing feedback from the actions taking place within the thread. It also supports two forms of cancellation, simple local thread interrupt and remote activity cancellation.

This class contains the usual constructors for thread objects, but ThreadGroup arguments have been replaced with Component arguments. The WTContext associated with the given Component is used to determine the thread group of the new thread.

For convenience, an additional start method is provided that allows the calling thread to wait until the WTThread calls ready. This simplifies the common task of synchronizing the new thread's access to volatile state that could be affected if the calling thread is allowed to continue.

Supported API: true
Extendable: true


Field Summary
private  Vector changeListeners
           
static String CREATED
          State property value for thread that is created but not yet started.
static String DONE
          State property value for thread that has terminated
private static boolean initialized
           
private static boolean INTERRUPT_SUPPORTED
           
private  boolean interrupted
           
private  Runnable interruptHandler
           
static String PROGRESS_COUNT
          Progress count property name
static String PROGRESS_PERCENT
          Progress percent property name
private  int progressCount
           
private  int progressPercent
           
private  boolean ready
           
static String RUNNING
          State property value for thread that has started running
private  String state
           
static String STATE
          State property name
private  String status
           
static String STATUS
          State property /** Status message property name
private static String versionID
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WTThread()
          Construct a new WTThread object.
WTThread(Component component)
          Construct a new WTThread object.
WTThread(Component component, Runnable target)
          Construct a new WTThread object with the target Runnable.
WTThread(Component component, Runnable target, String name)
          Construct a new WTThread object with the target Runnable and given name.
WTThread(Component component, String name)
          Construct a new WTThread object with the given name.
WTThread(Runnable target)
          Construct a new WTThread object with the target Runnable.
WTThread(Runnable target, String name)
          Construct a new WTThread object with the target Runnable and given name.
WTThread(String name)
          Construct a new WTThread object with the given name.
WTThread(ThreadGroup thread_group)
          Construct a new WTThread object.
WTThread(ThreadGroup thread_group, Runnable target)
          Construct a new WTThread object with the target Runnable.
WTThread(ThreadGroup thread_group, Runnable target, String name)
          Construct a new WTThread object with the target Runnable and given name.
WTThread(ThreadGroup thread_group, String name)
          Construct a new WTThread object with the given name.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void cancel()
          Cancel (interrupt) current server-side processing being performed by this thread.
static void currentProgressCount(int progress_count)
          Set the progress count for the current thread.
static void currentProgressPercent(int progress_percent)
          Set the percentage complete for the current thread.
static void currentStatus(String status)
          Set the status message for the current thread.
protected  void firePropertyChange(String property_name, int old_value, int new_value)
          Report a bound property update to any registered listeners.
protected  void firePropertyChange(String property_name, Object old_value, Object new_value)
          Report a bound property update to any registered listeners.
 int getProgressCount()
          Get the propress count.
 int getProgressPercent()
          Get the percentage complete.
 String getState()
          Get the state property.
 String getStatus()
          Get the status message.
private static ThreadGroup getThreadGroup(Component component)
           
private  void init()
           
 void interrupt()
          Interrupt this thread.
 boolean isInterrupted()
          Check if this thread has been interrupted.
 void ready()
          Notify parent thread that this thread is now ready for it to continue.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void run()
          Run method.
 void setInterruptHandler(Runnable interrupt_handler)
          Set an interrupt handler for this thread.
 void setProgressCount(int progress_count)
          Set the progress count.
 void setProgressPercent(int progress_percent)
          Set the percentage complete.
 void setStatus(String status)
          Set the status message.
 boolean start(boolean wait)
          Start this thread and optionally wait until the thread signals the caller to continue.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupted, isAlive, isDaemon, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versionID

private static final String versionID
See Also:
Constant Field Values

INTERRUPT_SUPPORTED

private static boolean INTERRUPT_SUPPORTED

initialized

private static boolean initialized

ready

private boolean ready

STATE

public static final String STATE
State property name

See Also:
Constant Field Values

state

private String state

CREATED

public static final String CREATED
State property value for thread that is created but not yet started.

See Also:
Constant Field Values

RUNNING

public static final String RUNNING
State property value for thread that has started running

See Also:
Constant Field Values

DONE

public static final String DONE
State property value for thread that has terminated

See Also:
Constant Field Values

STATUS

public static final String STATUS
State property /** Status message property name

See Also:
Constant Field Values

status

private String status

PROGRESS_PERCENT

public static final String PROGRESS_PERCENT
Progress percent property name

See Also:
Constant Field Values

progressPercent

private int progressPercent

PROGRESS_COUNT

public static final String PROGRESS_COUNT
Progress count property name

See Also:
Constant Field Values

progressCount

private int progressCount

changeListeners

private Vector changeListeners

interruptHandler

private Runnable interruptHandler

interrupted

private boolean interrupted
Constructor Detail

WTThread

public WTThread()
Construct a new WTThread object. The new thread becomes a member of the thread group associated with the current WTContext object.

Supported API: true

See Also:
WTContext

WTThread

public WTThread(Runnable target)
Construct a new WTThread object with the target Runnable. The new thread becomes a member of the thread group associated with the current WTContext object.

Supported API: true

Parameters:
target - the target Runnable
See Also:
WTContext

WTThread

public WTThread(Runnable target,
                String name)
Construct a new WTThread object with the target Runnable and given name. The new thread becomes a member of the thread group associated with the current WTContext object.

Supported API: true

Parameters:
target - the target Runnable
name - the thread name
See Also:
WTContext

WTThread

public WTThread(String name)
Construct a new WTThread object with the given name. The new thread becomes a member of the thread group associated with the current WTContext object.

Supported API: true

Parameters:
name - the thread name
See Also:
WTContext

WTThread

public WTThread(Component component)
Construct a new WTThread object. The new thread becomes a member of the thread group associated with the given Component object.

Supported API: true

Parameters:
component - the component that determines thread group.
See Also:
WTContext

WTThread

public WTThread(Component component,
                Runnable target)
Construct a new WTThread object with the target Runnable. The new thread becomes a member of the thread group associated with the given Component object.

Supported API: true

Parameters:
component - the Component that determines thread group.
target - the target Runnable
See Also:
WTContext

WTThread

public WTThread(Component component,
                Runnable target,
                String name)
Construct a new WTThread object with the target Runnable and given name. The new thread becomes a member of the thread group associated with the given Component object.

Supported API: true

Parameters:
component - the Component that determines thread group.
target - the target Runnable
name - the thread name
See Also:
WTContext

WTThread

public WTThread(Component component,
                String name)
Construct a new WTThread object with the given name. The new thread becomes a member of the thread group associated with the given Component object.

Supported API: true

Parameters:
component - the Component that determines thread group.
name - the thread name
See Also:
WTContext

WTThread

public WTThread(ThreadGroup thread_group)
Construct a new WTThread object. The new thread becomes a member of the passed ThreadGroup

Supported API: true

Parameters:
thread_group - the ThreadGroup that this thread is to be part of
See Also:
WTContext

WTThread

public WTThread(ThreadGroup thread_group,
                Runnable target)
Construct a new WTThread object with the target Runnable. The new thread becomes a member of the passed ThreadGroup Component object.

Supported API: true

Parameters:
thread_group - the ThreadGroup that this thread is to be part of
target - the target Runnable
See Also:
WTContext

WTThread

public WTThread(ThreadGroup thread_group,
                Runnable target,
                String name)
Construct a new WTThread object with the target Runnable and given name. The new thread becomes a member of the passed ThreadGroup

Supported API: true

Parameters:
thread_group - the ThreadGroup that this thread is to be part of
target - the target Runnable
name - the thread name
See Also:
WTContext

WTThread

public WTThread(ThreadGroup thread_group,
                String name)
Construct a new WTThread object with the given name. The new thread becomes a member of the passed ThreadGroup

Supported API: true

Parameters:
thread_group - the ThreadGroup that this thread is to be part of
name - the thread name
See Also:
WTContext
Method Detail

init

private void init()

getThreadGroup

private static ThreadGroup getThreadGroup(Component component)

start

public boolean start(boolean wait)
Start this thread and optionally wait until the thread signals the caller to continue. If wait is true, the calling thread waits until the new thread calls ready. This gives the new thread an opportunity to access any volatile state before proceeding. This method returns a boolean value to indicate whether the thread was started successfully or the caller was interrupted while waiting.

Supported API: true

Parameters:
wait - calling thread should wait until this thread signals ready
Returns:
true if thread started successfully, false if waiting was interrupted

ready

public void ready()
Notify parent thread that this thread is now ready for it to continue.

Supported API: true


run

public void run()
Run method. This method overrides the default run method to fire property change events for the state property.

Supported API: true


addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.

Supported API: true

Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.

Supported API: true

Parameters:
listener - the PropertyChangeListener to be removed

firePropertyChange

protected void firePropertyChange(String property_name,
                                  Object old_value,
                                  Object new_value)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.

Supported API: true

Parameters:
property_name - the programmatic name of the property that was changed
old_value - the old value of the property
new_value - the new value of the property

firePropertyChange

protected void firePropertyChange(String property_name,
                                  int old_value,
                                  int new_value)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.

Supported API: true

Parameters:
property_name - the programmatic name of the property that was changed
old_value - the old value of the property
new_value - the new value of the property

getState

public String getState()
Get the state property.

Supported API: true

Returns:
the state property

setStatus

public void setStatus(String status)
Set the status message.

Supported API: true

Parameters:
status - the status message string

getStatus

public String getStatus()
Get the status message.

Supported API: true

Returns:
the status message string

setProgressPercent

public void setProgressPercent(int progress_percent)
Set the percentage complete.

Supported API: true

Parameters:
progress_percent - percentage complete as an integer

getProgressPercent

public int getProgressPercent()
Get the percentage complete.

Supported API: true

Returns:
percentage complete as an integer

setProgressCount

public void setProgressCount(int progress_count)
Set the progress count.

Supported API: true

Parameters:
progress_count - progress count as an integer

getProgressCount

public int getProgressCount()
Get the propress count.

Supported API: true

Returns:
progress count as an integer

currentStatus

public static void currentStatus(String status)
Set the status message for the current thread. Ignored if the current thread is not an instance of WTThread.

Supported API: true

Parameters:
status - the status message string

currentProgressPercent

public static void currentProgressPercent(int progress_percent)
Set the percentage complete for the current thread. Ignored if the current thread is not an instance of WTThread.

Supported API: true

Parameters:
progress_percent - percentage complete as an integer

currentProgressCount

public static void currentProgressCount(int progress_count)
Set the progress count for the current thread. Ignored if the current thread is not an instance of WTThread.

Supported API: true

Parameters:
progress_count - percentage complete as an integer

setInterruptHandler

public void setInterruptHandler(Runnable interrupt_handler)
Set an interrupt handler for this thread. An interrupt handler is run when this thread is interrupted. It can be used to perform cleanup associated with interrupting this thread, such as interrupting of a remote thread in a server.

Supported API: true


interrupt

public void interrupt()
Interrupt this thread. If an interrupt handler has been set, it will be run.

Supported API: true


isInterrupted

public boolean isInterrupted()
Check if this thread has been interrupted. If thread interrupt is not supported (Netscape Communicator 4.0.4), this method will still return true the first time called after the interrupt method has been invoked.

Supported API: true

Returns:
true if this thread has been interrupted.

cancel

public void cancel()
Cancel (interrupt) current server-side processing being performed by this thread. The local thread is not interrupted. Instead, the server-side operation is interrupted and should return an exception to the local thread.

This method runs the thread's interrupt handler if it has been set. The interrupt handler is run in the same thread group as this thread.

Supported API: true