博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
What is the difference between concurrency, parallelism and asynchronous methods?
阅读量:5888 次
发布时间:2019-06-19

本文共 2115 字,大约阅读时间需要 7 分钟。

Ref: http://stackoverflow.com/questions/4844637/what-is-the-difference-between-concurrency-parallelism-and-asynchronous-methods

 

Concurrent and parallel are effectively the same principle as you correctly surmise, both are related to tasks being executes simultaneously although I would say that parallel tasks should be truly multitasking, executed "at the same time" whereas concurrent could mean that the tasks are sharing the execution thread while still appearing to be executing in parallel.

Concurrent and parallel几乎相同,都是跟task同时执行有关。parallel 的task是真正的同时执行,而concurrent表示共享执行单元但是看起来是同时执行

Asynchronous methods aren't directly related to the previous two concepts, asynchrony is used to present the impression of concurrent or parallel tasking but effectively an asynchronous method call is normally used for a process that needs to do work away from the current application and we don't want to wait and block our application awaiting the response.

Asynchronous 方法跟前两者没直接关系,异步用于表达concurrent or parallel task;但 asynchronous method call通常用于不直接写 current application,避免wait and block our application 

For example, getting data from a database could take time but we don't want to block our UI waiting for the data. The asynch call takes a call-back reference and returns execution back to your code as soon as the request has been placed with the remote system. Your UI can continue to respond to the user while the remote system does whatever processing is required, once it returns the data to your call-back method then that method can update the UI (or hand off that update) as appropriate.

比如,从数据库获取数据会占用时间,但我们不想block ui。asynch call会传入call-back 之后直接返回。UI可以继续执行,而远程系统完成之后callback会执行从而update你的ui

From the User perspective it appears like multitasking but it may not be.

这个看起来像multitasking 但可能不是


EDIT

It's probably worth adding that in many implementations an asynchronous method call will cause a thread to be spun up but it's not essential, it really depends on the operation being executed and how the response can be notified back to the system.

在很多asynchronous 的实现里会创建线程,但这不是必须的。这依赖于操作如何执行,以及response如何notified

转载地址:http://kjgix.baihongyu.com/

你可能感兴趣的文章
Binary Tree Paths
查看>>
RESTful 架构详解(转)
查看>>
Ueditor自定义ftp上传
查看>>
线程以及多线程
查看>>
PHP队列的实现
查看>>
单点登录加验证码例子
查看>>
[T-SQL]从变量与数据类型说起
查看>>
稀疏自动编码之反向传播算法(BP)
查看>>
二叉搜索树转换成双向链表
查看>>
会员数据化运营
查看>>
WebLogic和Tomcat的区别
查看>>
java类中 获取服务器的IP 端口
查看>>
调用约定__stdcall / __cdecl
查看>>
occActiveX - ActiveX with OpenCASCADE
查看>>
redmine
查看>>
css 序
查看>>
DirectshowLib摄像头拍照的”未找到可用于建立连接的介质筛选器组合“ 解决办法...
查看>>
Django之用户认证组件
查看>>
python如何使用 os.path.exists()--Learning from stackoverflow ...
查看>>
wcf-1
查看>>