python线程状态监测

一 代码

  1. from threading importThread
  2. import time
  3. def func1():
  4. time.sleep(10)
  5. t1=Thread(target=func1)
  6. print('t1:',t1.isAlive())
  7. t1.start()
  8. print('t1:',t1.isAlive())
  9. t1.join(5)
  10. print('t1:',t1.isAlive())
  11. t1.join()
  12. print('t1:',t1.isAlive())
二 运行结果
E:\python\python可以这样学\第13章 多线程与多进程编程\code>python ThirdExample.py
t1: False
t1: True
t1: True
t1: False

猜你喜欢

转载自cakin24.iteye.com/blog/2386358
今日推荐