thread: detached state

与其被称为state,可能称为flag更合适些,因为detached state并不是thread生命周期中的一个state(例如,running),而是一个flag,用来告诉OS当thread退出的时候,是否需要回收thread的resource。当设置为detached state时,如果thread退出了,OS会立即回收thread resource。如果没有设置detached state,thread的resouce会一直保存,直到这个thread的exit status被其他thread读取(通过thread_join读取)了,或者这个进程的所有thread都退出了。

thread state: thread有哪些state?怎样查看?linux kernel如何处理?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章