pthread_detach question

后端 未结 5 1937
鱼传尺愫
鱼传尺愫 2020-12-13 05:12

Till recently, I was under the impression that if you \"detach\" a thread after spawning it, the thread lives even after the \"main\" thread terminates.

But a litt

5条回答
  •  情话喂你
    2020-12-13 05:59

    pthread_detach does not do what you think it does - it indicates to the implementation that the space the thread with the specified ID is using can be reclaimed as soon as it terminates, ie. no pthread_join operation will be performed on it.

    All threads are terminated once the process containing them is terminated.

提交回复
热议问题