python编写的多线程程序,要求死循环执行多线程创建的线程,但是程序执行到一定时间后就在其中一个线程执0
jiao93632013.08.11浏览204次分享举报
python编写的一个多线程程序,要求死循环无限制的执行多线程创建的线程,但是程序执行到一定时间后就在其中一个线程中执行永远也出不来了,请问大家问题出在哪儿呢?万急呀,谢谢
# Thread class four
class groupCommunDom0(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
MulticasDom0.run()
self.lock.release()
time.sleep(1)
# Thread class five
class suspendTolerate(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
run_sh.suspendF()
self.lock.release()
time.sleep(1)
def test():
listthread = []
#分别创建线程放在列表中统一执行
#Creating thread
threadfour=groupCommunDom0()
listthread.append(threadfour)
threadfive=suspendTolerate()
listthread.append(threadfive)
#统一一起执行线程
for threadnum in listthread:
threadnum.start()
if __name__=='__main__':
while True:
test()