gpt4 book ai didi

c - 退出正在执行的 pthread

转载 作者:太空宇宙 更新时间:2023-11-04 08:14:51 25 4
gpt4 key购买 nike

如何自行终止 pthread 执行?

我有这个代码

while(1)
{
if(...)
{
terminate
}
work();
}

我必须使用 pthread_exit(); 但我应该给什么作为参数?

最佳答案

根据手册

The pthread_exit() function terminates the calling thread and returns a value via retval that (if the thread is joinable) is available to another thread in the same process that calls pthread_join(3).

这是您要提供给加入线程的任何值。如果不需要返回值,可以传NULL

关于c - 退出正在执行的 pthread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36397290/

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