[root@yyjk ~/sbin/F5]#cat test4.py
import threading
import time
threads = []
def fun9():
x=100
time.sleep(1)
x= x+1;
print x
return x
def fun10():
x=200
time.sleep(4)
x=x+4
print x
return x;
def fun11():
x=300
time.sleep(5)
x=x+5
print x;
return x
t9 = threading.Thread(target=fun9,name='fun9')
threads.append(t9)
t10 = threading.Thread(target=fun10,name='fun10')
threads.append(t10)
t11 = threading.Thread(target=fun11,name='fun11')
threads.append(t11)
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
[root@yyjk ~/sbin/F5]#vim test4.py
[root@yyjk ~/sbin/F5]#cat test4.py
import threading
import time
threads = []
def fun9():
x=100
time.sleep(1)
x= x+1;
print x
return x
def fun10():
x=200
time.sleep(7)
x=x+4
print x
return x;
def fun11():
x=300
time.sleep(5)
x=x+5
print x;
return x
t9 = threading.Thread(target=fun9,name='fun9')
threads.append(t9)
t10 = threading.Thread(target=fun10,name='fun10')
threads.append(t10)
t11 = threading.Thread(target=fun11,name='fun11')
threads.append(t11)
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
[root@yyjk ~/sbin/F5]#time python test4.py
101
305
204
real 0m7.051s
user 0m0.014s
sys 0m0.006s
[root@yyjk ~/sbin/F5]#