General Thread Information

To print thread or thread group information, use the following methods:

String toString()

Returns a string that describes the Thread object. Originally a method of the Object class, it is overridden by the Thread class to provide the name of the thread, the priority of the thread, and the name of the thread group to which the thread belongs.

String toString()

Returns a string that describes the ThreadGroup object. Originally a method of the Object class, it is overridden by the ThreadGroup class to provide the name of the thread group and the maximum priority of the group.

The toString() method is overridden by the thread classes to allow a sensible conversion of the object into a string. Hence, the following code:

Thread t = new TimerThread(this, 500);
    System.out.println(t);

yields the following output:

Thread[TimerThread-500,6,group applet-TimerApplet]
void list()

Prints the current layout of the thread group hierarchy, starting with the thread group on which the method is invoked. This is a method of the ThreadGroup class and simply prints the information to System.out. This method operates recursively on the thread group.

The information that is printed by the list() method is the information returned by the toString() methods. A sample list() of an applet may be as follows:

java.lang.ThreadGroup[name=system,maxpri=10]
    Thread[clock handler,11,system]
    Thread[Idle thread,0,system]
    Thread[Async Garbage Collector,1,system]
    Thread[Finalizer thread,1,system]
    java.lang.ThreadGroup[name=main,maxpri=10]
        Thread[main,5,main]
        Thread[AWT-Input,5,main]
        Thread[AWT-Motif,5,main]
        Thread[Screen Updater,4,main]
        AppletThreadGroup[name=group applet-Ticker,maxpri=6]
            Thread[thread applet-Ticker,6,group applet-Ticker]
            Thread[SUNW stock reader,5,group applet-Ticker]
            Thread[APPL stock reader,5,group applet-Ticker]
            Thread[NINI stock reader,5,group applet-Ticker]
            Thread[JRA stock reader,5,group applet-Ticker]
            Thread[ticker timer thread,4,group applet-Ticker]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset