如何自行终止 pthread 执行?
我有这个代码
while(1)
{
if(...)
{
terminate
}
work();
}
我必须使用 pthread_exit();
但我应该给什么作为参数?
最佳答案
根据手册
The
pthread_exit()
function terminates the calling thread and returns a value viaretval
that (if the thread is joinable) is available to another thread in the same process that callspthread_join(3)
.
这是您要提供给加入线程的任何值。如果不需要返回值,可以传NULL
。
关于c - 退出正在执行的 pthread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36397290/