判断线程是否已经启动 [英] Determine if thread has been started

查看:49
本文介绍了判断线程是否已经启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何判断一个python线程是否已经启动?有一个方法is_alive(),但这是在线程运行之前之前同时.

How to determine if a python thread has been started? There is a method is_alive() but this is true before and while a thread is running.

推荐答案

可以查看Thread实例的ident字段.Python 2.7 线程文档 描述了ident

You can look at the ident field of the Thread instance. The Python 2.7 documentation for Threading describes ident as

该线程的‘线程标识符’,如果线程没有,则为 None已开始.

The ‘thread identifier’ of this thread or None if the thread has not been started.

这篇关于判断线程是否已经启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆