网络编程
位置:首页>> 网络编程>> Python编程>> Python实现线程状态监测简单示例

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

作者:chengqiuming  发布时间:2023-12-07 20:31:25 

标签:Python,线程

本文实例讲述了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程序设计有所帮助。

来源:https://blog.csdn.net/chengqiuming/article/details/78601187

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com