It depends on what the functions do.
If they all use asynchronous I/O, you can simply call them so each can start that I/O, which will run in parallel.
function1();
function2();
function3();
Note: If you need to coordinate their completions, then you'll want to look into flow control libraries such as async
or q
.
But, if any of them are synchronous, then it gets trickier. You'll need to introduce asynchronous I/O around each of them. This can possibly be done through cluster
s or child_process
to start multiple node
processes.
But, it can't be done in JavaScript alone. JavaScript is still single-threaded with Node, so synchronous tasks will block other JavaScript code from executing. Asynchronous I/O is possible only through native C/C++ binaries using libuv
.