首页 > 解决方案 > Threading.thread() 在线程内创建线程?

问题描述

我有以下模块:

def monitor(self):
    # Do something
    periodic_thread = threading.Timer(30, self.monitor)
    periodic_thread.start()

这是否意味着,我们每 30 秒在一个线程中创建一个线程?如果我打印 current_thread,我有以下结果:

<_MainThread(MainThread, started 139936578074432)> 
 <_Timer(Thread-1, started 139936378812160)>
 <_Timer(Thread-2, started 139936370419456)>
 <_Timer(Thread-3, started 139936378812160)>

标签: pythonpython-multithreading

解决方案


推荐阅读