Python多线程求助,下面的子线程程序为什么会执行两遍
import threading
from time import ctime,sleep
import time
def music(func):
for i in range(2):
print ("Begin listening to %s. %s" %(func,ctime()))
sleep(4)
print("end listening %s"%ctime())
def movie(func):
for i in range(2):
print ("Begin watching at the %s! %s" %(func,ctime()))
sleep(5)
print('end watching %s'%ctime())
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 ("all over %s" %ctime())
music和movie为什么会执行两遍
#笔试题目##Python#
美的集团公司福利 815人发布