Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个socket.io监听套接字的服务器:
socket.io
io.sockets.on('connection', function(socket){ socket.on('myEvent', function(data){ socket.emit('eventReceived', { status: 1 }); }); });
这段代码在多线程中工作吗?如果两个客户端会发出myEvent事件,它会同时为两个客户端工作吗?还是会一个接一个地处理?
myEvent
非常感谢!
Node.js 中没有任何东西是多线程的,包括通过 npm 提供的任何包。核心中有一个实验性集群模块
http://nodejs.org/docs/v0.10.2/api/cluster.html