我想玩多線程,所以我可以做得更好,但由於一些奇怪的原因,我的代碼不想遵循命令。它假設進入while循環並打印,但它不會,並且也不會產生任何錯誤,所以哪些行是錯誤的?我在這個python腳本中犯了什麼錯誤?
#!/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,在哪個操作系統上? –