【发布时间】:2016-09-22 06:36:58
【问题描述】:
我已经使用 Node.js 有一段时间了。我在很大程度上知道它在内部是如何工作的(eventloop 和其他东西),但 ASP.NET Core 看起来与 Node.js 非常相似。
ASP.NET Core - Uses Kestrel (basically a fork of libuv)
Node.js - Uses libuv
ASP.NET Core - Tasks (though present in previous ASP.NET versions too)
Node.js - Promises
ASP.NET Core - Async/Await (though present in previous ASP.NET versions too)
Node.js - Async/Await
那么,以下结论是否正确:
Node.js 只有一个用于执行 javascript 代码(同步)的线程和许多用于后台异步操作的工作线程。
ASP.NET Core 使用多个线程来执行 .NET 代码(同步),并使用多个工作线程来执行后台异步操作。
Node.js 强制 I/O 为异步,因此您不会阻塞事件循环,但在 ASP.NET 中,用户也可以同步 I/O,从而阻塞线程,但由于它使用多个线程,因此整个应用程序不会不要被阻止。
【问题讨论】:
标签: javascript c# asp.net node.js multithreading