#coding=utf-8
import threading
from time import ctime,sleep
def music(func):
print "I was listening to %s. %s" % (func,ctime())
sleep(4)
print "I was finished %s. %s" % (func,ctime())
def move(func):
print "I was at the %s! %s"%(func,ctime())
sleep(6)
print "I was finished %s. %s" % (func,ctime())
threads = []
t1 = threading.Thread(target=music,args=(u'爱情买卖',))
threads.append(t1)
t2 = threading.Thread(target=move,args=(u'阿凡达',))
threads.append(t2)
if __name__=='__main__':
for t in threads:
t.setDaemon(True)
t.start()
for t in threads:
t.join()
print "all over %s "%ctime()
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10972173/viewspace-2121656/
,如需转载,请注明出处,否则将追究法律责任。