[英]Why not synchronously instead of asynchronously?
I am reading articles about the difference between synchronous and asynchronous behavior and ... I know I am stumbling upon words but I don't understand why the two terms are not used the other way around. 我正在阅读有关同步行为和异步行为之间的区别的文章,并且……我知道我在绊脚石,但我不明白为什么不以相反的方式使用这两个术语。
Synchronous means "occurring at the same time; coinciding in time; contemporaneous; simultaneous." 同步是指“同时发生;时间恰好一致;同时发生;同时发生”。 while asynchronous means "1.not occurring at the same time.2. (of a computer or other electrical machine) having each operation started only after the preceding operation is completed." 异步是指“ 1.不能同时发生2.计算机(或其他电机的)同时发生,只有在完成前一个操作后才开始每个操作”。 (dictionary.com) (dictionary.com)
However when it comes to programming the terms seem to be used differently. 但是,在编程时,这些术语的用法似乎有所不同。
The terms aren't used differently, you just have to understand how to interpret them. 这些术语没有不同的用法,您只需要了解如何解释它们即可。
Using Ajax as an example, because it is a common use case: 以Ajax为例,因为这是一个常见的用例:
The operation is: "Make an HTTP request, then do something with the response". 操作是:“发出HTTP请求,然后对响应进行处理”。
If it is synchronous, then that all happens in one long chunk (the bottom part of the diagram below). 如果它是同步的,则所有这些都将在一个较长的块中发生(如下图的底部)。
If it is asynchronous, then the HTTP request is sent and then the JavaScript engine does something else while it waits for the HTTP response to come back over the network. 如果是异步的,那么HTTP请求发送,然后JavaScript引擎做别的东西在等待HTTP响应回来在网络上。 Once the JS engine is no longer busy and the response has arrived, it does the rest of the Ajax operation. 一旦JS引擎不再忙碌并且响应已经到达,它将执行其余的Ajax操作。
The synchronous approach is "occurring at the same time" because it isn't split up with other stuff happening in the meantime. 同步方法是“同时发生”,因为它不会与同时发生的其他事情分开。
The second definition you quoted fits with no stretching at all. 您引用的第二个定义完全没有延伸。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.