【发布时间】:2012-12-21 12:18:32
【问题描述】:
如果我不关心我的线程的返回状态,我需要一个 pthread_exit 吗?
我想知道在我的数据化 pthread 中不调用 pthread_exit 是否可能存在一些微妙的资源问题。
谢谢。
【问题讨论】:
如果我不关心我的线程的返回状态,我需要一个 pthread_exit 吗?
我想知道在我的数据化 pthread 中不调用 pthread_exit 是否可能存在一些微妙的资源问题。
谢谢。
【问题讨论】:
pthread_exit() 的目的是如果有任何其他线程加入,则返回退出代码。
来自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.
所以,不使用也没关系。
【讨论】:
您不必致电pthread_exit()。从线程函数返回也同样有效,并且不会泄漏任何资源(当然,您仍然必须确保您的代码没有任何泄漏)。
【讨论】: