开发者

pthread_exit() and initial thread

When I use pthread_exit() in the initial thread, the initial thread switches in the terminated state. But I did not understand about the process.

Can exist a running process with the initial 开发者_如何学Pythonthread in the termitated state?


In pthreads, as long as any thread is running, the process will stay alive.

So yes, you can have a running process even though the initial thread has exited.

One thing that may be confusing you is what happens when the initial thread returns from main(). This is the equivalent of calling exit(). So if main() returns, your process will end. But if the initial thread calls pthread_exit() and there are other threads still alive, your process will remain alive.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜