异步Vs在NodeJS中同步 [英] Asynchronous Vs synchronous in NodeJS

查看:73
本文介绍了异步Vs在NodeJS中同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NodeJS的新手。我看到同一个任务有单独的异步和同步函数(例如:{ fs.writeFile,fs.writeFileSync },{ fs.read ,fs.readSync })。

I'm new to NodeJS. I have seen there are separate asynchronous and synchronous functions for the same task (ex: {fs.writeFile,fs.writeFileSync} , {fs.read, fs.readSync}).

任何人都能解释为什么会这样吗?有什么区别?

Can anyone explain why is that? and what is the difference?

推荐答案

异步:


  1. 发送请求

  2. 继续使用其他代码

  3. 回复随时可以回复

同步:


  1. 发送请求

  2. 等待回复

  3. 在回复后继续使用其他代码

这篇关于异步Vs在NodeJS中同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆