There is no threading support in Node, however there is support for spawning new node processes with a simple API for inter process communication. This approach was taken because the platforms that Node works on do not all have a common threading model and it was deemed simpler both for the node devs and node end users, to stick with worker processes.
However, I would definitely like true threads in node, not least because creating and killing a thread does not entail the overhead creating and killing a process does. On Sunday, February 17, 2013 4:15:48 PM UTC-8, RF wrote: > > Hi, > > I'm CS student who is new to Node, and I have two questions: > > 1. Is there currently an existing mechanism (e.g. module, core > functionality) that allows Node applications to spawn multiple threads (to > take advantage of multiple cores for true parallelism) ? > 2. If not, would this be a desirable feature? > > My understanding is that Node applications use a single thread to handle > everything by queuing events on an event loop to be processed sequentially. > I also understand that this is the core feature that allows Node to grant > efficiency gains for specific types of applications, and is the (main?) > source of Node's popularity. > > Given this fact then (and assuming that it's correct), it would seem > counter-intuitive to enable multi-threaded functionality in Node when there > are other languages/frameworks available potentially more suited to > multi-threaded behavior. > However, an example use case that I'm thinking of is a situation whereby > an existing Node application needs to be adapted or extended with some > functionality that would benefit from true parallelism. > So, maybe 3 or 4 threads could be created that would handle 3 or 4 tasks > more efficiently than Node's existing sequential behavior, while still > taking advantage of Node's established execution model in other areas of > the application. > > I was thinking along the lines of creating a Node module that exposes an > interface for creating threads and supplying them with the necessary > function (and also some mechanisms for dealing with shared data concurrency > and consensus issues). > I have searched unsuccessfully through available resources in an attempt > to answer the above questions, so I'm hoping that someone can help me out. > > Regards, > -Rob > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
