-
daemon
-
A boolean value indicating whether this thread is a daemon thread (True) or not (False). This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when no alive non-daemon threads are left.
当daemon被设置为True时,如果主线程退出,那么子线程也将跟着退出,
反之,子线程将继续运行,直到正常退出。
本文详细介绍了Python中守护线程的概念及其工作原理。守护线程主要用于后台任务处理,当主线程结束时,守护线程会一同终止,而非守护线程则会继续执行直至完成。文章解释了如何设置守护线程,并探讨了其对于程序整体运行的影响。
401

被折叠的 条评论
为什么被折叠?



