如何知道 pthread 是否已死 [英] How to know if a pthread died
本文介绍了如何知道 pthread 是否已死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何知道 pthread 是否已死?
How can one know if a pthread died?
有没有办法检查pthreads的状态?
Is there a way to check a pthreads status?
推荐答案
if(pthread_kill(the_thread, 0) == 0)
{
/* still running */
}
参见:pthread_kill
注意:使用 pthread_kill() 测试是否存在固有风险线程仍在运行.请参阅此帖子以获取解释:如何确定pthread是否存活?
Note: there is an inherent risk to using pthread_kill() to test if a thread is still running. See this post for an explanation: How do I determine if a pthread is alive?
这篇关于如何知道 pthread 是否已死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文