|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
wt.util.WTThread
public class WTThread
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
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| 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 |
getStatus()
Get the status message. |
String |
getWtThreadState()
Get the state property. |
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, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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 |
| Constructor Detail |
|---|
public WTThread()
WTThread object.
The new thread becomes a member of the thread group associated with the current
WTContext object.
WTContextpublic WTThread(Runnable target)
WTThread object with the target Runnable.
The new thread becomes a member of the thread group associated with the current
WTContext object.
target - the target RunnableWTContext
public WTThread(Runnable target,
String name)
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.
target - the target Runnablename - the thread nameWTContextpublic WTThread(String name)
WTThread object with the given name. The new thread becomes
a member of the thread group associated with the current WTContext object.
name - the thread nameWTContextpublic WTThread(Component component)
WTThread object.
The new thread becomes a member of the thread group associated with the given
Component object.
component - the component that determines thread group.WTContext
public WTThread(Component component,
Runnable target)
WTThread object with the target Runnable.
The new thread becomes a member of the thread group associated with the given
Component object.
component - the Component that determines thread group.target - the target RunnableWTContext
public WTThread(Component component,
Runnable target,
String name)
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.
component - the Component that determines thread group.target - the target Runnablename - the thread nameWTContext
public WTThread(Component component,
String name)
WTThread object with the given name. The new thread becomes
a member of the thread group associated with the given Component object.
component - the Component that determines thread group.name - the thread nameWTContextpublic WTThread(ThreadGroup thread_group)
WTThread object.
The new thread becomes a member of the passed ThreadGroup
thread_group - the ThreadGroup that this thread is to be part ofWTContext
public WTThread(ThreadGroup thread_group,
Runnable target)
WTThread object with the target Runnable.
The new thread becomes a member of the passed ThreadGroup
Component object.
thread_group - the ThreadGroup that this thread is to be part oftarget - the target RunnableWTContext
public WTThread(ThreadGroup thread_group,
Runnable target,
String name)
WTThread object with the target Runnable
and given name. The new thread becomes a member of the passed ThreadGroup
thread_group - the ThreadGroup that this thread is to be part oftarget - the target Runnablename - the thread nameWTContext
public WTThread(ThreadGroup thread_group,
String name)
WTThread object with the given name.
The new thread becomes a member of the passed ThreadGroup
thread_group - the ThreadGroup that this thread is to be part ofname - the thread nameWTContext| Method Detail |
|---|
public boolean start(boolean wait)
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.
wait - calling thread should wait until this thread signals ready
public void ready()
public void run()
run in interface Runnablerun in class Threadpublic void addPropertyChangeListener(PropertyChangeListener listener)
listener - the PropertyChangeListener to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener - the PropertyChangeListener to be removed
protected void firePropertyChange(String property_name,
Object old_value,
Object new_value)
property_name - the programmatic name of the property that was changedold_value - the old value of the propertynew_value - the new value of the property
protected void firePropertyChange(String property_name,
int old_value,
int new_value)
property_name - the programmatic name of the property that was changedold_value - the old value of the propertynew_value - the new value of the propertypublic String getWtThreadState()
public void setStatus(String status)
status - the status message stringpublic String getStatus()
public void setProgressPercent(int progress_percent)
progress_percent - percentage complete as an integerpublic int getProgressPercent()
public void setProgressCount(int progress_count)
progress_count - progress count as an integerpublic int getProgressCount()
public static void currentStatus(String status)
WTThread.
status - the status message stringpublic static void currentProgressPercent(int progress_percent)
WTThread.
progress_percent - percentage complete as an integerpublic static void currentProgressCount(int progress_count)
WTThread.
progress_count - percentage complete as an integerpublic void setInterruptHandler(Runnable interrupt_handler)
public void interrupt()
interrupt in class Threadpublic boolean isInterrupted()
true the first time called after the interrupt
method has been invoked.
isInterrupted in class Threadtrue if this thread has been interrupted.public void cancel()
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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||