java-User (foreground) thread and daemon (background) thread

Source: Internet
Author: User

1. Daemon (background) threads Daemon Thread

The role of the daemon is to facilitate the operation of other threads, such as a garbage collection thread that is a daemon thread

A. Child threads created by the daemon thread are also daemon threads

B. You can set the thread as the daemon thread (Setdaemon (Boolean on)), but you must throw the exception before calling the Start method.

C. Do not assume that all applications can be assigned to daemon for service, such as read-write operations or computational logic.

Because once all the user threads have finished executing, the virtual machine exits, and the daemon thread is forced to exit.

2. User (foreground) thread

java-User (foreground) thread and daemon (background) thread

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.