python线程状态监测

来源:互联网 发布:新的淘宝店怎么推广 编辑:程序博客网 时间:2024/05/19 19:32

一 代码

  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
原创粉丝点击