|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
wt.util.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
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 |
private static final String versionID
private static boolean INTERRUPT_SUPPORTED
private static boolean initialized
private boolean ready
public static final String STATE
private String state
public static final String CREATED
public static final String RUNNING
public static final String DONE
public static final String STATUS
private String status
public static final String PROGRESS_PERCENT
private int progressPercent
public static final String PROGRESS_COUNT
private int progressCount
private Vector changeListeners
private Runnable interruptHandler
private boolean interrupted
Constructor Detail |
public WTThread()
WTThread
object.
The new thread becomes a member of the thread group associated with the current
WTContext
object.
WTContext
public 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 Runnable
WTContext
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 nameWTContext
public 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 nameWTContext
public 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 Runnable
WTContext
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 Runnable
name
- 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 nameWTContext
public 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 Runnable
WTContext
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 Runnable
name
- 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 |
private void init()
private static ThreadGroup getThreadGroup(Component component)
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()
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- the PropertyChangeListener
to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- the PropertyChangeListener
to be removedprotected 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 propertyprotected 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 getState()
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()
public boolean isInterrupted()
true
the first time called after the interrupt
method has been invoked.
true
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 |