线程与并行,它们有何不同? [英] Threading vs Parallelism, how do they differ?

查看:22
本文介绍了线程与并行,它们有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

线程和并行有什么区别?

What is the difference between threading and parallelism?

哪一个比另一个有优势?

Which one has advantage over the other?

推荐答案

Daniel Moth(我的前同事)- 线程/并发与并行 文章解释了这一切.

引用:

为了利用我们软件的多个内核,最终必须使用线程.由于这个事实,一些开发人员陷入将多线程等同于并行的陷阱.那不是准确...您可以在单核机器上进行多线程处理,但是你只能在多核机器上并行

To take advantage of multiple cores from our software, ultimately threads have to be used. Because of this fact, some developers fall in the trap of equating multithreading to parallelism. That is not accurate...You can have multithreading on a single core machine, but you can only have parallelism on a multi core machine

快速测试:如果您在单核机器上使用线程并且它对您的场景非常有意义,那么您不是在进行并行",而是在进行多线程.

The quick test: If on a single core machine you are using threads and it makes perfect sense for your scenario, then you are not "doing parallelism", you are just doing multithreading.

这篇关于线程与并行,它们有何不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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