util.testsuite
Class PrintThreads

java.lang.Object
  extended by util.testsuite.PrintThreads

public class PrintThreads
extends java.lang.Object

PrintThreads prints all the Threads in the current JVM. This class will work in both applications and applets. When run in an applet, this class attempts to gracefully handle the various security restrictions concerning getting the parent of a ThreadGroup. The output includes the number of threads and whether the current thread is the Swing Event Dispatch Thread.

To get a stack trace for each thread:
Under Unix, try kill -3 pid, where pid is the process id from ps.
Under Windows, try Ctrl-Break.

Since:
Ptolemy II 1.0
Version:
$Id: PrintThreads.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Christopher Hylands, based on code from Fusion Systems Group
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (cxh)

Constructor Summary
PrintThreads()
           
 
Method Summary
private static java.lang.String _getHeader()
           
private static java.lang.String _stringFormat(java.lang.String inputString, int length)
           
static java.lang.String allThreadGroups()
          Return a String containing all the ThreadGroups in the JVM that are descendents of the root ThreadGroup.
static java.lang.String allThreads(boolean indicateEventDispatchThread)
          Return a string containing all the threads in the JVM who are members of ThreadGroups which are descendants of the root ThreadGroup.
static java.lang.ThreadGroup rootThreadGroup()
          Get the root ThreadGroup of the Java Virtual Machine.
static java.lang.String toThreadDescription(java.lang.Thread thread)
          Return a user friendly description of the thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrintThreads

public PrintThreads()
Method Detail

rootThreadGroup

public static java.lang.ThreadGroup rootThreadGroup()
Get the root ThreadGroup of the Java Virtual Machine. This method assumes that the current Thread is a member of a ThreadGroup which is a descendant of the root ThreadGroup.

Returns:
The root thread group.

allThreadGroups

public static java.lang.String allThreadGroups()
Return a String containing all the ThreadGroups in the JVM that are descendents of the root ThreadGroup.

Returns:
A string naming all the ThreadGroups.

allThreads

public static java.lang.String allThreads(boolean indicateEventDispatchThread)
Return a string containing all the threads in the JVM who are members of ThreadGroups which are descendants of the root ThreadGroup.

Parameters:
indicateEventDispatchThread - true if we should indicate which thread is the Swing Event Dispatch Thread.
Returns:
A string naming all the threads.

toThreadDescription

public static java.lang.String toThreadDescription(java.lang.Thread thread)
Return a user friendly description of the thread. We could use Thread.toString(), but that is hard to read.

Parameters:
thread - The thread
Returns:
A user friendly description of the thread.

_getHeader

private static final java.lang.String _getHeader()

_stringFormat

private static final java.lang.String _stringFormat(java.lang.String inputString,
                                                    int length)