为什么不在弹出后运行任务并返回true? 我在运行中从C+C++并发运行了以下示例,并传递函数A、B和C与其提交、打印POP和肯定返回true,但是为什么不打印“开始任务” 它似乎没有运行任务() #包括 #包括 #包括 #包括 类连接线程 { std::向量和线程; 公众: 显式连接线程(std::vector&threads):线程(threads) {} ~join_threads() { 对于(无符号长i=0;isubmit((*b)); 池->提交(*c)); printf(“提交完成\n”); while(池->完成==false) std::this_线程::sleep(std::毫秒(1)); }

为什么不在弹出后运行任务并返回true? 我在运行中从C+C++并发运行了以下示例,并传递函数A、B和C与其提交、打印POP和肯定返回true,但是为什么不打印“开始任务” 它似乎没有运行任务() #包括 #包括 #包括 #包括 类连接线程 { std::向量和线程; 公众: 显式连接线程(std::vector&threads):线程(threads) {} ~join_threads() { 对于(无符号长i=0;isubmit((*b)); 池->提交(*c)); printf(“提交完成\n”); while(池->完成==false) std::this_线程::sleep(std::毫秒(1)); },c++,concurrency,c++11,C++,Concurrency,C++11,修复所有编译错误后,将在linux上使用GCC 4.6.1进行编译并运行,生成以下输出: begin push 0push 1push 2push 3push 4push 5submit start submit finish poptask start a task end poptask start b task end poptask start c task end 在这一点之后,它仍然处于无休止的循环中,因为done永远不会变为true 看起来“任务开始”实际上是打印出来的。这是如何

修复所有编译错误后,将在linux上使用GCC 4.6.1进行编译并运行,生成以下输出:

begin
push 0push 1push 2push 3push 4push 5submit start
submit finish
poptask start
a
task end
poptask start
b
task end
poptask start
c
task end
在这一点之后,它仍然处于无休止的循环中,因为
done
永远不会变为
true


看起来“任务开始”实际上是打印出来的。

这是如何编译的?除了缺少的include之外,gcc告诉我
错误:“std::atomic\u bool thread\u pool::done”是私有的
错误:“sleep”不是“std::this\u thread”的成员
,并且
错误:“毫秒”不是“std”的成员。
(它是std::chrono::毫秒)非常感谢,在修复了所有警告之后,它可以运行了,似乎声明了joiner的优先级并解决了问题