JavaScript Event循环和Node.js事件循环之间有什么不同? [英] What is the different between JavaScript Event loop and Node.js Event loop?

查看:130
本文介绍了JavaScript Event循环和Node.js事件循环之间有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中,事件循环用于引擎。下面是一张图表来说明这个。


Node.js事件循环在单个线程下运行,这意味着您编写的应用程序代码在单个线程上进行评估。 Nodejs本身使用了libuv下面的许多线程,但是在编写nodejs代码时你永远不必处理那些线程。


但是,关于node.js事件循环,我仍然是抽象的。




  • 是否有任何图像可以更清楚地介绍它?

  • 这两个事件之间有什么不同?循环?


解决方案


这两个事件循环之间的区别是什么?


没什么。 Nodejs JavaScript引擎 1



1:或者更确切地说,其中一个,有其他引擎实现相同的语言和相同的事件循环概念。


是否有任何图像可以更清楚地介绍它?


有很多。但我觉得动画效果更好:-) Philip Roberts的这个jsconf演讲在各地都受到称赞。


In JavaScript, the event loop is used in the engine. Here is one diagram to illustrate it from this article.

For Node.js, the event loop also implemented here. Quoting from this question.

The Node.js event loop runs under a single thread, this means the application code you write is evaluated on a single thread. Nodejs itself uses many threads underneath trough libuv, but you never have to deal with with those when writing nodejs code.

However, it is still abstract for me about node.js event loop.

  • Is there any image to introduce it more clearly?
  • What's the different between those two event loops?

解决方案

What's the difference between those two event loops?

Nothing. Nodejs is the JavaScript engine1.

1: Or rather, one of them, there are other engines implementing the same language and the same event loop concept.

Is there any image to introduce it more clearly?

There are many. But I think an animation is better :-) This jsconf talk by Philip Roberts is praised everywhere.

这篇关于JavaScript Event循环和Node.js事件循环之间有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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