这篇文章主要介绍了Python实现线程状态监测,结合简单实例形式分析了Python线程start启动、sleep推迟运行、isAlive判断等方法使用技巧,需要的朋友可以参考下

本文实例讲述了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实现线程状态监测简单示例(python线程监控)  Python 线程 状态监测 脚本之家 第1张

 

希望本文所述对大家Python程序设计有所帮助。


注:相关教程知识阅读请移步到Python教程频道。
转载请说明出处
知优网 » Python实现线程状态监测简单示例(python线程监控)

发表评论

您需要后才能发表评论