Node.js的单线程模型有点傻
By
lincanbin
at 2018-06-22 • 0人收藏 • 2277人看过
var http = require('http');
function fibonacci(n) {
if(n === 0 || n === 1)
return n;
return fibonacci(n-1) + fibonacci(n-2);
}
http.createServer(function (request, response) {
console.log('收到一个request');
fibonacci(10000);
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(1234);
console.log('Server running at http://127.0.0.1:1234/');真的是一点CPU密集的工作都不能接啊。
3 个回复 | 最后更新于 2018-06-25
登录后方可回帖

粤公网安备 44030602003677号
get了