python死循环程序占用线程_python编写的多线程程序,要求死循环执行多线程创建的线程,但是程序执行到一定时间后就在其中一个线程执...

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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值