串行升压线连接环路VS在主并行 [英] serial boost thread joins in loop vs parallel in main

查看:131
本文介绍了串行升压线连接环路VS在主并行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在试图了解这个答案,我发现很多类似的问题,当然还有文档,但没有解释原因

In trying to understand this answer, I've found many similar questions and of course the docs but no explanation why.

为什么说加入这叫在可以并行运行,而加入这叫在一个循环中不能?

Why is it that joins called in main can run parallel while joins called in a loop in main cannot?

推荐答案

想到事件的序列。这间

start thread 1
start thread 2
wait for thread 1 to finish
wait for thread 2 to finish

start thread 1
wait for thread 1 to finish

start thread 2
wait for thread 2 to finish

这应该是显而易见的是,在第二种情况下,两个线程从未在同一时间运行。

It should be obvious that, in the second case, the two threads never run at the same time.

这篇关于串行升压线连接环路VS在主并行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆