how do i create a non-blocking asynchronous function in node.js?

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-05-20T21:31:03Z Indexed on 2010/05/20 23:10 UTC
Read the original article Hit count: 131

Filed under:

How do I create a non-blocking asynchronous function? Below is what I'm trying to achieve but my program is still blocking...

var sys = require("sys");

function doSomething() {
  sys.puts("why does this block?");
  while(true);
}

setTimeout(doSomething,0);
setTimeout(doSomething,0);
setTimeout(doSomething,0);

sys.puts("main");

© Stack Overflow or respective owner

Related posts about node.js