python编写的一个多线程程序,要求死循环执行多线程创建的线程,但是程序执行到一定程度后就在其中一个线程中执行出不来了,请问大家问题出在哪儿呢?万急呀,谢谢
时间:2010-10-23
来源:互联网
python编写的一个多线程程序,要求死循环无限制的执行多线程创建的线程,但是程序执行到一定时间后就在其中一个线程中执行永远也出不来了,请问大家问题出在哪儿呢?万急呀,谢谢
import threading
import run_sh
import time
from ccManager import cc_manager
import ccManager
import sys
import groupCommunicationDom0
MulticasDom0=groupCommunicationDom0.MulticasDom0()
# Thread class two
class startup(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
run_sh.start()
self.lock.release()
time.sleep(1)
# Thread class three
class resumeTolerate(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
run_sh.resumeF()
self.lock.release()
time.sleep(1)
# 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
threadtwo=startup()
listthread.append(threadtwo)
threadthree=resumeTolerate()
listthread.append(threadthree)
threadfour=groupCommunDom0()
listthread.append(threadfour)
threadfive=suspendTolerate()
listthread.append(threadfive)
#统一一起执行线程
for threadnum in listthread:
threadnum.start()
if __name__=='__main__':
while True:
test()
import threading
import run_sh
import time
from ccManager import cc_manager
import ccManager
import sys
import groupCommunicationDom0
MulticasDom0=groupCommunicationDom0.MulticasDom0()
# Thread class two
class startup(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
run_sh.start()
self.lock.release()
time.sleep(1)
# Thread class three
class resumeTolerate(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.lock = threading.Lock()
def run(self):
self.lock.acquire()
run_sh.resumeF()
self.lock.release()
time.sleep(1)
# 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
threadtwo=startup()
listthread.append(threadtwo)
threadthree=resumeTolerate()
listthread.append(threadthree)
threadfour=groupCommunDom0()
listthread.append(threadfour)
threadfive=suspendTolerate()
listthread.append(threadfive)
#统一一起执行线程
for threadnum in listthread:
threadnum.start()
if __name__=='__main__':
while True:
test()
作者: romeany 发布时间: 2010-10-23
望python高手或者其他熟悉多线程编程的高手指点下,谢谢啊
作者: romeany 发布时间: 2010-10-24
突然想起用队列应该能解决这个问题,试一试吧
作者: romeany 发布时间: 2010-10-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28