A JVM process starts with several threads inside

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.