2016-08-18 53 views
0
import threading,time 

def auto2(): 

    while 1: 
     print ("hello master") 
     time.sleep(2) 

def auto1(): 

    while 1: 
     print "hello" 
     time.sleep(3) 

x=threading.Thread(target=auto1(),args=()) 

y=threading.Thread(target=auto2(),args=()) 

x.start() 

y.start() 
+0

需要明確的是爲大家,請描述你的預期行爲和實際行爲,甚至如果代碼很簡單。 –

回答

1
import threading, time 
def auto2(): 
    while 1: 
     print("hello master") 
     time.sleep(2) 
def auto1(): 
    while 1: 
     print ("hello") 
     time.sleep(3) 
x = threading.Thread(target=auto1) 
y = threading.Thread(target=auto2) 
x.start() 
y.start() 

目標=自動1() - >目標= AUTO1

+0

是必需的,何時使用? – Perseus784

相關問題