1

first argument of pthread_create is pthread_t (which is typedef'ed to long), which I understand is thread ID.

Does it set this value to zero when thread finishes execution? I would like to use it to check if the thread is running

4

1 回答 1

0

不,pthread_tpthread 库一旦初始化就不会更改它。将pthread_t对象传递pthread_join()给等待线程完成。如果您想在不阻塞的情况下进行确定,您可以通过在某个共享对象中为其状态设置指示器来让线程进行协作。

于 2012-04-26T22:28:39.270 回答