我有这段代码,我怎么能阻止func2和func1?像Thread(target = func1).stop()
这样的东西不起作用
import threading
from threading import Thread
def func1():
while True:
print 'working 1'
def func2():
while True:
print 'Working2'
if __name__ == '__main__':
Thread(target = func1).start()
Thread(target = func2).start()
最好使用消息队列来让其他线程停止。
不能告诉线程停止,必须使其在目标函数中返回
相关问题 更多 >
编程相关推荐