|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--ip1.ex14.JFtpThread
A thread that has a message queue and children. This serves as the base for all of JFtp's threads. It provides mechanisms to push and pop messages to and from its message queue. It also provides support for the thread hierarchy as a JFtpThread has a parent (null for the top thread) and can have children. There is also support for displaying the running threads by assigning the threadTree member of the toplevel thread. Threads signal a change in their queue or their children to the toplevel thread and the thread view is updated recursively.
JFtp,
JFtpControl,
JFtpData| Nested Class Summary | |
(package private) class |
JFtpThread.QueueItem
An item of the action queue. |
| Field Summary | |
protected java.util.Vector |
children
The thread's children. |
protected static int |
counter
Instance counter. |
protected int |
id
This thread's id. |
private javax.swing.tree.DefaultMutableTreeNode |
idleNode
|
protected javax.swing.tree.DefaultMutableTreeNode |
node
The thread's node. |
protected JFtpThread |
parent
The thread's parent. |
protected java.util.Vector |
queue
The message queue. |
int |
state
The thread's state. |
static int |
STATE_EXITED
The thread has exited. |
static int |
STATE_NOTRUNNING
The thread is not running. |
static int |
STATE_SHUTDOWN
We are shutting down. |
protected javax.swing.JTree |
threadTree
An optional JTree for displaying the thread's queue and children. |
protected boolean |
threadTreeChanged
Has the threadTree changed since the last refresh? |
protected java.lang.String |
type
Type of thread. |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
JFtpThread(JFtpThread parent,
java.lang.String type)
Shorter version of the constructor (not tree). |
|
JFtpThread(JFtpThread parent,
java.lang.String type,
boolean withThreadTree)
The constructor. |
|
| Method Summary | |
protected void |
addChild(JFtpThread theThread)
Add a child thread. |
protected JFtpThread.QueueItem |
addQueue(JFtpThread.QueueItem item)
Queue a command. |
protected void |
debug(java.lang.String msg)
Output a debugging message. |
protected void |
dumpQueue()
|
protected JFtpThread |
getChild(int index)
Return the requested child. |
protected JFtpThread |
getRoot()
Return the root thread. |
protected boolean |
isBusy()
Is this thread busy (that is are there messages in its queue)? |
protected JFtpThread.QueueItem |
peekQueue()
Peek at the next item in the queue. |
void |
propagateTreeChange()
Propagate a notice that the tree view needs a refresh. |
protected void |
queueShutdown()
Queue a shutdown of the thread. |
protected JFtpThread.QueueItem |
readQueue()
Read the next item in the queue. |
protected void |
refreshNode()
Refresh the node representing this thread. |
protected void |
refreshThreadView()
Update the thread view |
protected void |
removeChild(JFtpThread theThread)
Remove a child thread then updates the toplevel thread view. |
protected void |
reset()
Clear the thread's queue and kill all its children. |
void |
run()
The run function, must be overriden to do anything useful. |
protected void |
shutdown()
Perform a shutdown. |
java.lang.String |
toString()
Convert to String representation. |
protected void |
waitShutdown(JFtpThread theThread)
Wait for a thread to exit. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int STATE_NOTRUNNING
public static final int STATE_SHUTDOWN
public static final int STATE_EXITED
protected java.util.Vector queue
protected java.util.Vector children
protected JFtpThread parent
protected javax.swing.JTree threadTree
protected boolean threadTreeChanged
protected java.lang.String type
protected static int counter
protected int id
public int state
protected javax.swing.tree.DefaultMutableTreeNode node
private javax.swing.tree.DefaultMutableTreeNode idleNode
| Constructor Detail |
public JFtpThread(JFtpThread parent,
java.lang.String type,
boolean withThreadTree)
parent - the parent thread, or nulltype - type of this threadwithThreadTree - do we want a thread tree associated with this thread?
public JFtpThread(JFtpThread parent,
java.lang.String type)
parent - the parent thread, or nulltype - type of this thread| Method Detail |
protected void addChild(JFtpThread theThread)
theThread - the thread to addprotected JFtpThread.QueueItem addQueue(JFtpThread.QueueItem item)
item - the command to queueprotected void debug(java.lang.String msg)
msg - the message to printprotected void dumpQueue()
protected JFtpThread getChild(int index)
protected JFtpThread getRoot()
protected boolean isBusy()
protected JFtpThread.QueueItem peekQueue()
public void propagateTreeChange()
protected void queueShutdown()
protected JFtpThread.QueueItem readQueue()
protected void refreshNode()
protected void refreshThreadView()
protected void removeChild(JFtpThread theThread)
theThread - the child to removeprotected void reset()
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprotected void shutdown()
public java.lang.String toString()
toString in class java.lang.Threadprotected void waitShutdown(JFtpThread theThread)
theThread - the thread to wait for
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||