【发布时间】:2013-03-31 12:46:06
【问题描述】:
对不起,老问题。我已经澄清了。如何使用我糟糕的线程类启动停止线程?
编辑:它在循环中,我想在代码开头再次重新启动它。如何启动-停止-重启-停止-重启?
我的班级:
import threading
class Concur(threading.Thread):
def __init__(self):
self.stopped = False
threading.Thread.__init__(self)
def run(self):
i = 0
while not self.stopped:
time.sleep(1)
i = i + 1
在主代码中,我想要:
inst = Concur()
while conditon:
inst.start()
#after some operation
inst.stop()
#some other operation
【问题讨论】:
标签: python multithreading