與其被稱爲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如何處理?