Asynchronous / 异步
The term asynchronous refers to two or more objects or events not existing or happening at the same time (or multiple related things happening without waiting for the previous one to complete). In computing, the word “asynchronous” is used in two major contexts.
异步指事件不会同一时间发生,或者说是多个相关事件不等待前一事件完成就发生。计算机技术中,异步一词用于两大背景。
Networking and communications
网络与通信
Asynchronous communication is a method of exchanging messages between two or more parties in which each party receives and processes messages whenever it’s convenient or possible to do so, rather than doing so immediately upon receipt. Additionally, messages may be sent without waiting for acknowledgement, with the understanding that if a problem occurs, the recipient will request corrections or otherwise handle the situation.
异步通信用来在双方或多方之间交流信息。当接收和处理信息不难或可以进行时,各方才会接收和处理信息,而非接收信息后立马执行。此外,信息可能发送后不等待确认通知,因为其明白如果有问题出现,那么接受者会请求修正,要不就处理情况。
For humans, e-mail is an asynchronous communication method; the sender sends an email and the recipient will read and reply to the message when it’s convenient to do so, rather than doing so at once. And both sides can continue to send and receive messages whenever they wish, instead of having to schedule them around each other.
对人类来说,电子邮件就是一种异步通信方式;发送者发送一封邮件,接着接收者方便时读取和回复该邮件,而非立马这样做。双方可以继续随意发送和接收信息,而非必须安排何时进行。
When software communicates asynchronously, a program may make a request for information from another piece of software (such as a server), and continue to do other things while waiting for a reply. For example, the AJAX (Asynchronous JavaScript and XML) programming technique—now usually simply “Ajax”, even though JSON is usually used rather than XML in modern applications—is a mechanism that requests relatively small amounts of data from the server using HTTP, with the result being returned when available rather than immediately.
软件异步通信时,程序可能会向另一软件(如服务器)请求信息,在等待回复的同时会进行其它行为。例如,AJAX(Asynchronous JavaScript and XML)编程技术利用HTTP向服务器请求较少数据,结果不立即返回,而是在易于获得时返回。(现在通常简写为”Ajax”,不过现在的应用不常用XML,而是用JSON)。
Software design
软件设计
Asynchronous software design expands upon the concept by building code that allows a program to ask that a task be performed alongside the original task (or tasks), without stopping to wait for the task to complete. When the secondary task is completed, the original task is notified using an agreed-upon mechanism so that it knows the work is done, and that the result, if any, is available.There are a number of programming techniques for implementing asynchronous software. See the article Asynchronous JavaScript for an introduction to them.
异步程序设计更为详细地阐释该概念,其编写的代码使程序能够要求一项任务和原先任务一起运行,不需停止任务去等待另一任务完成。第二项任务完成时,原先的任务利用一个约定好的机制得到通知,这样得知任务完成,可以的话就返回结果。有一些编程技术用来实现异步软件,查看文章Asynchronous JavaScript 去了解基本信息吧。
Learn more
了解更多
Technical reference
参考
- Fetching data from the server (Learning Area) 从服务器获取数据
- Synchronous 同步