The role of daemon attributes in Python multithreaded programming

Source: Internet
Author: User

There is a main thread during the script run, and if a child thread is created in the main thread, one of the following two situations may occur when the main thread ends depending on the Daemon property value of the child thread:

  • If the Daemon property of a child thread is false, the main thread will detect if the child thread ends at the end, and if the child thread is still running, the main thread waits for it to complete before exiting;

  • If the Daemon property of a child thread is true, the thread exits without checking the child thread at the end of the run, and all child threads with a value of true daemon end with the main thread, regardless of whether the run is complete or not.

The value of property daemon defaults to False and must be set before calling the start () method if modifications are required. It is also important to note that the above description does not apply to the interactive mode or script run mode in the idle environment, because the main thread in the environment is terminated only when it exits Python idle.

Turn from: 53899426

The role of daemon attributes in Python multithreaded programming

Related Article

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.