退出正在执行的 pthread

Exit pthread that is executing

如何自我终止 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).

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