如果我不关心返回值,我需要pthread_exit吗
Do I need pthread_exit if I don't care of return value
如果我不关心线程的返回状态,我需要有一个pthread_exit吗?
我想知道是否有一些微妙的资源问题与不调用pthread_exit在我的数据pthreads。
谢谢。
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.
所以,如果你不使用它也没有什么区别
您不必调用pthread_exit()
。从线程函数返回同样可以很好地工作,并且不会泄漏任何资源(当然,您仍然必须确保您的代码没有任何泄漏)。
相关文章:
- 在 c++11 中为 pthread 设置调度参数
- 我如何测试代码没有调用 exit()
- 如果不包含 pthread,为什么 GCC 的线程标准库实现会抛出异常?
- exit(0) 和 raise(SIGTERM) 有什么区别?
- pthread只有在线程数量较少时才可以正常工作
- "Program ended with exit code: 0"出现在我的输出的开头?
- pthread执行时间比顺序执行时间差
- 使用 -pthread 如何不违反 ODR 规则?
- 使用 pthread 的多线程
- 销毁 pthread 互斥体和 C++ 中的取消初始化顺序
- 函数 AfxEndThread 中的读取访问冲突"pThread-> was nullptr"
- 锁定步进pthread互斥
- Pthread段错误,使用指向main中变量的指针
- pthread导致的内存泄漏
- GCC:--静态链接到pthread的整个存档配方在最近的GCC版本中停止工作
- exit(EXITT_FAILURE)在c和c++中是如何工作的
- 在C++中使用exit()退出程序有问题吗
- 正确地编写一个类,并将pthread与vlc库和c++一起使用
- 直接读取 pthread 互斥锁的所有者字段是否安全?
- 为什么 pthread 会减慢代码速度?