python

超轻量级php框架startmvc

Python实现线程状态监测简单示例

更新时间:2020-05-25 20:48:01 作者:startmvc
本文实例讲述了Python实现线程状态监测。分享给大家供大家参考,具体如下:#-*-coding:utf-8-*

本文实例讲述了Python实现线程状态监测。分享给大家供大家参考,具体如下:


# -*- 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 线程 状态监测