简体   繁体   English

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

[英]Do I need pthread_exit if I don't care of return value

If I don't care about the return status of my thread, would I need to have a pthread_exit? 如果我不关心我的线程的返回状态,我需要有一个pthread_exit吗?

I'm wondering if there might be some subtle resource problems associated with not calling pthread_exit in my datached pthreads. 我想知道在我的数据库pthreads中是否存在与不调用pthread_exit相关的一些细微资源问题。

Thanks. 谢谢。

The purpose pthread_exit() is to return the exit code if any other threads that joins . 目的pthread_exit()用于返回任何其他连接的线程的退出代码。

From the manual : 手册

   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.

So, it makes no difference if you don't use it. 所以,如果你不使用它没有任何区别。

You don't have to call pthread_exit() . 您不必调用pthread_exit() Returning from the thread function would work equally well, and will not leak any resources (of course, you still have to ensure that your code doesn't have any leaks). 从线程函数返回将同样有效,并且不会泄漏任何资源(当然,您仍然必须确保您的代码没有任何泄漏)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM