What threads are initialized when you start an application? (I heard six. What do they do?)

Paul Done

Theres an easy way to list the threads running in a JVM, just write the following class, compile and run from the command line....

public class ThreadDisplayer
    public static void main( String[] args )
        ThreadGroup topGroup = Thread.currentThread().getThreadGroup().getParent();

For the JVM I was running (shows java version "1.2.2" Classic VM (build JDK-1.2.2_006, native threads, symcjit), when I run java -version), I got the following ouput....

    Thread[Signal dispatcher,5,system]
    Thread[Reference Handler,10,system]

This shows thread groups (name and priority) and threads (name, priority and parent group name). For my JVM there seems to be 3 system threads. I'm guessing that the Signal thread is handling O.S. event notification, Reference Handler is handling object reference counts and Finalizer is handling garbage collection. However this may not be totally correct 'cos I was always under the impression that the g.c. thread had a low priority by default.

The Main thread will be the one that calls the main() method of your java program and the other two threads seem to be there to handle JIT compilation.

I don't know where the java spec stipulates which threads must exist by default, or whether the threads created are purely up to the JVM vendor. Certainly the prescence of the two JIT threads suggests the latter.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact