How do I count the number of running threads (pthreads)?

后端 未结 3 1097
眼角桃花
眼角桃花 2021-01-19 23:46

If I search for counting the number of threads an application has, all the answers involve external programs like top. I want to count the threads within the ap

3条回答
  •  青春惊慌失措
    2021-01-20 00:09

    If you can't read /proc you are a bit in trouble, unless your program communicate with another program which reads /proc

    If you don't want to read /proc because of portability concerns, you might use a library which abstracts that a bit, like libproc does

提交回复
热议问题