简体   繁体   中英

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 thread 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM