0
当某些变量值设置为true时如何终止线程?当某些变量设置为true时立即终止线程
import threading
class test(threading.Thread):
def __init__(self):
self.stopThread = False
self.start():
def start(self):
while not self.stopThread:
callOtherFunction //which takes alomst 30 sec to execute
def stop(self):
self.stopThread = True
现在的问题是,如果启动函数被调用和while循环开始那么它会检查下一个迭代的停止条件,当它完成了它的内部工作,所以如果呼叫到callOtherFunction做出那么仍然等待30秒退出..我想立即终止线程时,变量设置。可能吗?
可能重复[有什么办法杀死Python中的线程?](http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in- python) –
或者你应该使用多处理,如果你想立即杀死 –