When writing Java programs, usually we have only one main function (and no other thread or runnable program) called single-threaded programs. But the so-called single-threaded program we wrote is just a thread in the JVM, and the JVM itself is a multithreaded program, with at least one garbage collector thread.
Just installed a NetBeans6.0, inside with a parser package, so wrote a HelloWorld program, check the JVM start, there will be several threads:
The result: In addition to my main thread, there are four threads:
- Finalizer Thread: A Java system thread that executes "object completion" before garbage collection;
- Signal Dispatcher Thread: Java system thread that processes local operating system signals for the JVM;
- Reference Handler Thread: A high-priority Java system thread that places suspended objects in the queue.
- Attach Listener Thread: User thread.
My personal guess is:
1. The task of the Finalizer thread is to call the Finalize () method for garbage collection.
2, Signal Dispatcher thread of the task is to deal with the operating system, shielding the operating system, so that Java to achieve cross-platform of the thing should be it dry.
3. The task of the Reference handler thread is to mark an unused object and place it in the queue of the recycled object so that the finalizer thread can release the memory operation.
4. Last Attach Listener thread: This should be my Java profile thread. Not related to the JVM.
So, a comprehensive analysis can be drawn: When a simplest Java program starts, the JVM will start 3 threads in addition to our main thread.
A JVM process starts with several threads inside