首页 > 解决方案 > 如何在 Python 中停止守护线程

问题描述

我想杀死或停止这个线程,我不知道如何安全地做到这一点,我知道当程序停止时守护线程会被杀死,但我想杀死或停止线程。

def a():
   def b():
     os.system()
t1 = threading.Thread(target=b, daemon=True)
return t1
class A:
   def test():
      t1 = a()
      t1.start()

      """I want to stop this thread here."""

标签: python-3.xmultithreadingthread-safetypthreadspython-multithreading

解决方案


推荐阅读