当前位置:网站首页>Promise --- synchronize? Asynchronous?
Promise --- synchronize? Asynchronous?
2022-07-16 06:40:00 【There's the sun】
Preface : When it comes to asynchronous programming, the first thing that comes to mind is ES6 New syntax Promise, but Promise Is it synchronous or asynchronous ?
Synchronous programming ? Asynchronous programming ?
In judging Promise Before synchronous or asynchronous , We need to understand what synchronization is ? What is asynchronous
Analysis of examples :
background : i'm hungry , I want to eat fried chicken in the North , But some people are greedy for the chicken pot in the South .
Scheme 1 : First go north to buy fried chicken , After buying fried chicken, go to the south to buy chicken pot .
Option two : Take out , Do both at the same time , Whoever does it first will send it first
Plan 1: buy chicken pot after you get the fried chicken , A process with a fixed sequence is called Sync
The process of scheme 2, who is the fastest and who is the first, is called asynchronous
Promise Synchronous or asynchronous ?
Promise yes ES6 The introduction of a new solution to asynchronous programming , but Promise It's synchronous
give an example :
let learn = new Promise((resolve, reject) => {
console.log(' It is synchronization that I appear first ');
});
console.log(' It's asynchrony that I appear first ');Print it on the console :
![]()
analysis :
“ It's asynchrony that I appear first ” Is faster than “ It is synchronization that I appear first ” Fast parsing speed
In case of asynchronous execution , The first output of the console should be “ It's asynchrony that I appear first ”
However, the print results are executed in sequence , Therefore, it can be judged as Synchronous execution
summary :Promise It's synchronous
边栏推荐
- 免费获取erlang安装包!!
- [Verilog] sub module connection related problems (adder and Its Optimization)
- ES6 let 、const 详解
- 3.6 formatting numbers and strings
- Win10安装程序提示“不能打开要写入的文件xxxxx”如何解决
- 【ICCV2021】Tokens-to-Token ViT: Training Vision Transformers From Scratch on ImageNet
- C语言动态内存分配原理以及堆区的使用(malloc、calloc、realloc、free)
- codeblocks的官网下载与安装
- VScode自动添加注释
- stm32f429+LAN4720A+lwip 问题记录及解决
猜你喜欢

2021-07-31

【 pcb】 quelques expériences sur la conception du matériel et le dessin des PCB dans le jeu électrique (mise à jour continue)

使用MessageBox实现窗口表白小程序(附带源码)

STM32—TIM3输出PWM信号驱动MG996R舵机(按键控制)

Comment utiliser l'oscilloscope virtuel dans Keil 5 pour la simulation logicielle

Virtual memory location structure (reserved area, code area, stack area, heap area, literal constant area) and variable modifiers (const, auto, static, register, volatile, extern)

嵌入式软件开发 STM32F407 蜂鸣器 标准库版

Using idea IntelliJ to view bytecode files

Excel-2

GY-53红外激光测距模块的使用以及pwm模式代码的实现
随机推荐
在Colab上训练yolov3(一)
STM32F103 guider - example game Tetris
Keil5 shortcut key
Friendly zeropi uboot, kernel compilation,
电脑常规操作
max3232ese 问题记录及解决
VScode设置语言为中文,并且解决中文注释乱码问题。
Use of functions with variable length parameters (C language < stdarg. H>)
工作方法小结
Aidl for Hal
在中断程序中,需要清中断标志,作用是什么?
[Verilog] sub module connection related problems (adder and Its Optimization)
[matlab] matlab lesson 2 - preliminary drawing
【MATLAB】matlab第二课——绘图初步
语音芯片JQ8400的使用心得
Embedded software development stm32f407 running lantern Hal library version
Automation instrumentation and process control (final review)
IIC通讯
嵌入式软件开发 STM32F407 按键输入 标准库版
【PCB】關於電賽——硬件設計和PCB繪制的一些心得(持續更新)