2016-08-18 54 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

相关问题