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.
精彩评论