实现并发join的方法

时间:2024-08-28 11:35:20
import threading
import time def music():
print("begin to listen %s" %time.ctime())
time.sleep(3)
print("stop to listen %s" %time.ctime()) def game():
print("begin to listen %s" % time.ctime())
time.sleep(5)
print("stop to listen1 %s" % time.ctime()) if __name__ =='__main__': t1 = threading.Thread(target=music) t2 = threading.Thread(target=game) t1.start()
# t1.join()
t2.start() # t1.join()
t2.join() print("ending") # l = []
#
# for i in range(2):
# threading.Thread(target=music)