2011年10月9日

python原生结束线程的方法

摘要: Python的threading 本身没有提供.kill()方法来结束线程。但是只需要一个小小的变通就可以实现。一个caller线程在里面调用需要控制时间的tHhandle线程并把tHhandle线程设置.setDaemon()方法为True。caller线程结束,tHandle线程就会跟着结束。# encoding: UTF-8import threadingimport time#完全原生强制结束python线程的方法。转载请注明来自博客园def func(tHandle,timeout): #caller 函数 print 'in time control.' tHan. 阅读全文

posted @ 2011-10-09 18:30 小风x 阅读(11426) 评论(4) 推荐(1) 编辑

导航