Shekhar
Shekhar

Reputation: 11788

Can we program multi threaded behaviour using Node.js?

I want to write an program which will simulate data coming from some set of sensors. So I need some mechanism by which I can spawn few thousand threads which will send data to database at the same time (time stamp from all the threads has to be same) and then sleep for some time interval and then again send some data.

As spawning thousand threads will not be efficient and it might crash system I thought Node.js is better suited for this kind of requirement. Please correct me if I am wrong.

Can we do something like this using call back functions of Node.js? Or is there any other open source api/tool which can generate random time series kind of data?

Upvotes: 0

Views: 194

Answers (1)

dmck
dmck

Reputation: 7861

JavaScript is single threaded, this includes Node. You could simulate this however by running multiple Node processes.

To communicate between processes you could use 0MQ Node bindings from: https://github.com/JustinTulloss/zeromq.node

Upvotes: 2

Related Questions