import threading
from time import ctime, sleep
def music(arg1):
for i in range(2):
print('listening to %s %s' %(arg1, ctime()))
sleep(4)
def movie(arg2):
for i in range(2):
print('look at the %s %s' %(arg2, ctime()))
sleep(5)
threads = []
t1 = threading.Thread(target=music, args=('爱情买卖',))
threads.append(t1)
t2 = threading.Thread(target=movie, args=('太极',))
threads.append(t2)
if __name__ == '__main__':
for t in threads:
t.setDaemon(True)
t.start()
t.join()
print('\nall over %s' %ctime())
多线程__Python
最新推荐文章于 2021-01-13 04:21:41 发布