zoukankan      html  css  js  c++  java
  • 并行parallel和并发concurrent的区别

    http://stackoverflow.com/questions/1050222/concurrency-vs-parallelism-what-is-the-difference

    Concurrency is when two or more tasks can start, run, and complete in overlapping time periods. It doesn't necessarily mean they'll ever both be running at the same instant. Eg. multitasking on a single-core machine.

    Parallelism is when tasks literally run at the same time, eg. on a multicore processor.

    Quoting Sun's Multithreaded Programming Guide:

    • Concurrency: A condition that exists when at least two threads are making progress. A more generalized form of parallelism that can include time-slicing as a form of virtual parallelism.

    • Parallelism: A condition that arises when at least two threads are executing simultaneously.

    参考:

    http://www.cnblogs.com/ty408/p/5801148.html

    http://www.cnblogs.com/zlcxbb/p/5754346.html

    Concurrency vs Parallelism

    https://www.codeproject.com/Articles/1267757/Concurrency-vs-Parallelism

    This article will explain the difference between concurrency and parallelism. Concurrency vs parallelism has been a debated topic for a long time.

    Actual Parallelism Vs Feel of Parallelism

    Technical vocabulary in IT industry is sometimes very confusing and “Concurrency” and “Parallelism” are some of them. Many developers think “Concurrency and parallelism means executing at the same time” which is right 50%, but with one big difference:

    • Concurrency gives you a feel of parallelism and parallelism as the name implies is actual parallelism.

    Feel of parallelism means you execute multiple tasks on the same core and the core switches context between tasks and serves them. You can also term this has time slicing / overlapping time period because your single core is just dedicating some time to one task and then some time to other.

    Actual parallelism means you execute multiple tasks on multiple cores parallely.

    Note: “Concurrency is a broader term and Parallelism is a subset of it”.

    Mapping to the real world, the left image depicts parallelism the right image depicts concurrency.

    Why a Feel of Parallelism and Why Not Actual?

    In order to achieve actual parallelism, we need dedicated cores, separate memory and so on.
    We need MORE RESOURCES.

    Let’s say we want to show a progress bar for some task completed. Now we really do not want to have separate cores allocated to display the progress.

    Image 3 for Concurrency vs Parallelism

    We do not want PERFORMANCE here, we want that physiologically the end user feels both tasks are happening simultaneously.

    We want to just beat the human eye capability of 100 FPS and give an illusion of parallelism without stressing our computer resources. But let’s say we want to process big Excel files with a million records, then yes we would love to have actual parallelism to achieve performance.

  • 相关阅读:
    强化学习 | D3QN原理及代码实现
    Airtest入门及多设备管理总结
    JS图片base64压缩
    ABP框架
    .net gof23种设计模式
    VS2013添加Socket
    VS2013用InstallShield打包winfrom项目
    .net core3.1 log4net无法写日志
    git commit 修改提交说明信息
    screen 使用总结
  • 原文地址:https://www.cnblogs.com/chucklu/p/5808080.html
Copyright © 2011-2022 走看看