• 并行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.

  • 相关阅读:
    python基础(1)#1,2,3,4可组成多少不重复的三位数
    HTML/CSS 学习笔记
    (转) 杨元:CSS浮动(float,clear)通俗讲解
    前端:HTML
    Servlet
    Maven 安装
    单例模式
    项目随笔
    树状结构--迭代
    DB的封装
  • 原文地址:https://www.cnblogs.com/chucklu/p/5808080.html
Copyright © 2020-2023  润新知