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.

转载于:https://www.cnblogs.com/wpcockroach/archive/2013/01/29/2881931.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值