【发布时间】:2014-02-07 17:52:56
【问题描述】:
首先,我是 pthreads 的新手,所以如果我完全误解了,请告诉我。
我搜索了返回值的正确方法,发现了这个链接 How to return a value from thread in C 和 https://linuxprograms.wordpress.com/category/pipes/ 。
所以我可以共享由起始线程或管道信息控制的位置,但最后一个值不能放在某个堆栈上?为什么我不能像 shell(如 bash)调用程序时那样 return?
(据我了解,如果它是 C++,则可能有一个常规返回值,但是(根据我读到的内容,我认为这里可能是 https://computing.llnl.gov/tutorials/pthreads/)POSIX 并没有完全为 C++ 定义,只是 C .)
【问题讨论】:
-
建议:
std::thread -
听起来你正在寻找
pipe()而不是线程......你是在加入后获得“返回值”吗?? -
AnotherTest,std::thread 不是 C++11 的 pthread 实现吗? πάντα ῥεῖ,不,它必须使用 pthread。
-
@ConfusedStack pthreads 提供
pthread_join()!!那么没有什么?你似乎真的很困惑......