多线程和并行计算有什么关系和区别

 我来答
huanglenzhi
2017-12-20 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
采纳数:117533 获赞数:517215
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。

向TA提问 私信TA
展开全部

并行是将问题分解交给不同的CPU内核去处理。

而多线程是串行,使用时间分片。

很明显并行比多线程具有更高的CPU利用率,因此效率相对更高。来自MSDN:(TPL - Task Parallel Library)

The TPL scales the degree of concurrency dynamically to most efficiently use all the processors that are available. In addition, the TPL handles the partitioning of the work, the scheduling of threads on the ThreadPool, cancellation support, state management, and other low-level details. By using TPL, you can maximize the performance of your code while focusing on the work that your program is designed to accomplish.

从MSDN的解释可以看出,TPL也包含了将task分配到多线程的过程,但是它比MT多了更多细节的东西,比如分解work,状态管理,取消机制和更多的low-level details,这些都是简单的多线程做不到的(除非你自己实现这一套类似的东西)。

推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式