C库函数来获得活动的线程数 [英] c library function to get number of active threads
问题描述
我发展的C.线程UNIX应用程序多有一个简单的方法来获得同时活动线程数的计数?我不希望有写code跟踪活动线程的数量,如果它已经可以为我在图书馆完成了! : - )
I'm developing a multi threaded Unix application in C. Is there a simple way to get the count of the number of simultaneously active threads? I don't want to have to write the code to keep track of the number of active thread if it already can be done for me by the library! :-)
我使用POSIX的pthreads,我想写尽可能code为Unix和类Unix系统,便于携带。
I'm using POSIX pthreads, and I'm trying to write as portable as possible code for Unix and Unix-like systems.
推荐答案
不,不是的pthreads中的本身的。 POSIX线程试图只指定的原始类型或者基本效用结构,以及<一个href=\"http://www.opengroup.org/onlinepubs/009695399/functions/pthread%5Fjoin.html#tag%5F03%5F533%5F08\">considers甚至在pthread_join
一个方便的功能,而不是一个原始的。
No, not in pthreads per se. POSIX Threads tries to specify only primitives or basic utility constructs, and considers even pthread_join
a convenience function, not a primitive.
某些图书馆可能会提供非便携式解决方案(寻找 _np
在HP-UX上的名称,例如),但对于pthreads的本身,你对你自己的。
Certain libraries may offer non-portable solutions (look for _np
in the name on HP-UX, for instance), but for pthreads per se, you're on your own.
这篇关于C库函数来获得活动的线程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!