本文实例讲述了Python实现线程状态监测。分享给大家供大家参考,具体如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# -*- coding:utf-8 -*- from threading import Thread import time def func1(): time.sleep( 10 ) t1 = Thread(target = func1) print ( 't1:' ,t1.isAlive()) t1.start() print ( 't1:' ,t1.isAlive()) t1.join( 5 ) print ( 't1:' ,t1.isAlive()) t1.join() print ( 't1:' ,t1.isAlive()) |
运行结果:
希望本文所述对大家Python程序设计有所帮助。
原文链接:https://blog.csdn.net/chengqiuming/article/details/78601187