【发布时间】:2016-06-28 20:49:38
【问题描述】:
我尝试使用多线程,以便更好地处理它,但由于某些奇怪的原因,我的代码不想遵循命令。假设进入一个while循环并打印,但它没有,而且它也没有引发任何错误,那么错误在哪一行?
#!/usr/bin/env python
#
#
#
import random
import thread
import time
import sys
import os
def DisplayA(name,wait):
while True:
print 'Display: 1';time.sleep(wait)
def DisplayB(name,wait):
while True:
print 'Display: 2';time.sleep(wait)
def DisplayC(name,wait):
while True:
print 'Display: 3';time.sleep(wait)
thread.start_new_thread(DisplayA,('Display1',2))
thread.start_new_thread(DisplayB,('Display2',3))
thread.start_new_thread(DisplayC,('Display3',5))
【问题讨论】:
-
这在我的终端上可以正常工作... ...
-
您看到的输出是什么?什么都没有?另外,哪个版本的 Python,在哪个操作系统上?
标签: python multithreading python-2.7