如果我不关心返回值,是否需要pthread_exit?

如果我不关心我的线程的返回状态,我需要有一个pthread_exit吗?

我想知道在我的数据库pthreads中是否存在与不调用pthread_exit相关的一些细微资源问题。

谢谢。

您不必调用pthread_exit() 。 从线程函数返回将同样有效,并且不会泄漏任何资源(当然,您仍然必须确保您的代码没有任何泄漏)。

目的pthread_exit()用于返回任何其他连接的线程的退出代码。

从手册 :

  Performing a return from the start function of any thread other than the main thread results in an implicit call to pthread_exit(), using the function's return value as the thread's exit status. 

所以,如果你不使用它没有任何区别。