zoukankan      html  css  js  c++  java
  • Concurrency vs. Parallelism: The Difference

    最近在看一些并行编程相关的内容,经常碰到两个单词:concurrency和parallelism。一直没有搞明白这两个词到底啥区别,总感觉是一样的。所以,google是必须的。不过不管是Stack Overflow还是其他搜索结果,个人总觉得说明得不够让人好理解。今天看书,算是看到一份个人觉得非常完整的说明:

        Concurrency is a concept related to multitasking and asynchronous input-output (I/O).  It usually refers to the existence of multiple threads of execution that may each get a slice of time to execute before being preempted by another thread, which also gets a slice of time.  Concurrency is necessary in order for a program to react to external stimuli such as user input, devices, and sensors.  Operating systems and games, by their very nature, are concurrent, even on one core.

        With parallelism, concurrent threads execute at the same time on multiple cores.  Parallel programming focuses on improving the performance of applications that use a lot of processor power and are not constantly interrupted when multiple cores are available.

        The goals of concurrency and parallelism are distinct.  The main goal of concurrency is to reduce latency by never allowing long periods of time to go by without at least some computation being performed by each unblocked thread.  In other words, the goal of concurrency is to prevent thread starvation.

        Concurrency is required operationally.  For example, an operating system with a graphical user interface must support concurrency if more than one window at a time can update its display area on a single-core computer.  Parallelism, on the other hand, is only about throughput.  It’s an optimization, not a functional requirement.  Its goal is to maximize processor usage across all available cores; to do this, it uses scheduling algorithms that are not preemptive, such as algorithms that process queues or stacks of work to be done.

  • 相关阅读:
    Vcenter虚拟化三部曲----SQL Server 2008 R2 数据库安装
    Vcenter虚拟化三部曲----VMWare ESXi 5.5安装及配置
    SaltStack 自动化工具
    KVM虚拟化
    redis单节点集群
    linux--yum源,源码包
    运维工程师常用命令(持续更新)
    TARS基金会:构建微服务开源生态
    TarsGo新版本发布,支持protobuf,zipkin和自定义插件
    .NET 发送电子邮件
  • 原文地址:https://www.cnblogs.com/wpcockroach/p/2881931.html
Copyright © 2011-2022 走看看