gpt4 book ai didi

c - `func`完成后,线程会自动退出吗?

转载 作者:行者123 更新时间:2023-12-03 12:52:57 26 4
gpt4 key购买 nike

是否需要从线程例程中显式调用pthread_exit

示例代码:

pthread_create(&pth, NULL, (void *)func, parg);

... func() {
...
//do I have to call pthread_exit() here?
return 0;
}

最佳答案

pthread_create 文档说:

If the start_routine returns, the effect is as if there was an implicit call to pthread_exit() using the return value of start_routine as the exit status.



因此,不需要,无需显式调用它。

关于c - `func`完成后,线程会自动退出吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6215008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com