如何检查由模块线程(Python 3 _thread)创建的线程是否正在运行?
不过,线程模块对我来说是有效的。怎么检查由线程模块(在Python 3中是 _thread)创建的线程是否在运行呢?当线程正在执行的函数结束时,线程也会结束吗?
def __init__(self):
self.thread =None
......
if self.thread==None or not self.thread.isAlive() :
self.thread = thread.start_new_thread(self.dosomething,())
else:
tkMessageBox.showwarning("XXXX","There's no need to have more than two threads")
我知道“thread”模块里没有叫做 isAlive() 的函数,那有没有其他的替代方法呢?
但是使用“threading”模块也没有什么理由,对吧?