Is there a way to make a blocking call in Node.Js? -


The program is sometimes difficult in the program, using continuous (callback) rather than sequential execution models. Can nodes call?

Yes, you can do this for example fs.readFile () instead of fs.readFileSync ( ) Can read a file with. Each library typically offers a XXXSync method for synchronous / blocking methods.

But you should not often use the sync method Remember that Node.js uses single threads of execution for JavaScript code. If you block this thread, you block it for everyone (Unlike C # / Java, where a new thread will be created for each request.)

If the asynch approach is for you Too much, you would want to use other platforms (Ruby, Python, PHP).


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -