pthread 线程状态 [英] pthread thread state

查看:59
本文介绍了pthread 线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种机制可以用来判断 pthread 线程当前是否正在运行或已退出?如果线程尚未退出,pthread_join() 是否有方法可以在特定时间段后超时?

Is there a mechanism that I can use to tell if a pthread thread is currently running, or has exited? Is there a method for pthread_join() that is able to timeout after a specific period of time if the thread has not yet exited?

推荐答案

我刚刚将线程包装在 C++ 类中,并保留了一个状态变量,以便稍后检查.

I just ended up wrapping the thread in a C++ class and keeping a state variable around that could be checked later.

这篇关于pthread 线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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