看大卫Beazley的(http://www.dabeaz.com)video about python threads,我是想出来的东西与线程与蟒蛇线程尝试,如何停止线程
def countdown(n):
while n > 0:
if not n % 100000:
print n
n -= 1
>> from threading import Thread
>> t1=Thread(target=countdown,args=(10000000,))
>> t1.start();t1.join()
>>Ctrl-C
这给
>>10000000
9900000
9800000
9700000
9600000
Ctrl-C9500000
9400000
...
400000
300000
200000
100000
----------
KeyboardInterrupt :
...
现在我试图找到状态的线程
>>t1.isAlive()
>>False
所以,我试图再次运行线程,whi ch造成了错误
>>t1.start();t1.join()
--------------
RuntimeError: thread already started
为什么会发生这种情况?有没有办法阻止线程?
你杀了进程你想如何运行它Ctrl-C发送信号来杀死正在运行的进程。 – 0x90