1 import threading
 2 import time
 3 def f0():
 4     pass
 5 def f1(a1,a2):
 6     time.sleep(10)
 7     f0()
 8     print("1")
 9 
10 t1 = threading.Thread(target=f1,args=(111,123))
11 # t.setDaemon(True)
12 t1.start()
13 t1.join(2)#等2秒
14 t2 = threading.Thread(target=f1,args=(111,123))
15 # t.setDaemon(True)
16 t2.start()
17 t2.join()#等待线程结束
18 t3 = threading.Thread(target=f1,args=(111,123))
19 # t.setDaemon(True)
20 t3.start()
21 t3.join()

 

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-04-10
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案