在我的场景中,主线程正在使用pthread_create()
创建3个子线程。
创建子线程后,子线程任务完成并到达pthread_exit()
语句但父级仍未到达语句pthread_join()
以收集子级的状态。
但不知何故,最后,我能够获得父线程中线程的状态。
如何可能,请帮助我?
答案 0 :(得分:0)
那么,是否意味着pthread_exit()将处于等待状态,直到 父母收集身份?
pthread_exit()
结束;线程不是处于等待状态,而是 a"僵尸线程" ,如此note:
Failure to join with a thread that is joinable (i.e., one that is not detached), produces a "zombie thread". Avoid doing this, since each zombie thread consumes some system resources, and when enough zombie threads have accumulated, it will no longer be possible to create new threads (or processes).
(retval
存储在pthread_t
缓冲区内。)