Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,909 members, 7,817,683 topics. Date: Saturday, 04 May 2024 at 05:11 PM |
Nairaland Forum / Science/Technology / Programming / Child Threads Handled In Node.js (787 Views)
I Have This Annoying Bug In Node Js For The Past 5 Days..help / Building An API In Node.js And Taking It Live On A VPS / Free PHP, Node js ,Mongo db, Angular And C# Proje Source Code With Documentation (2) (3) (4)
Child Threads Handled In Node.js by Arjunkumar09: 9:59am On Jan 29, 2020 |
Hello Everyone, I want to know how are ‘Child Threads’ handled in Node.js? In my previous interview, I have faced this question but I didn’t know the answer. Can anyone knows these query and help me out or suggest some node.js based interview questions as a beginner point. |
Re: Child Threads Handled In Node.js by peterincredible: 8:14pm On Jan 29, 2020 |
Arjunkumar09:pls i dont get your question child thread asin how pls put code so we can understand or explain further with some code am willing to help but i just dont get ure question |
Re: Child Threads Handled In Node.js by makavele: 8:39pm On Jan 29, 2020 |
peterincredible: ^ The question albeit a very advanced part of javascript, is pretty clear and straightforward. Nodejs doesn't allow the users interfere and mess with the running of child threads. By default, it is a single-thread non-blocking runtime, as we all know. However, if there is a need to perform any asynchronous I/O task, then Node.js can spawn child-threads. You can invoke this though, using the 'child-process' module that comes with Node. I did something like this a while back: const oldSpawn = childProcess.exec; It relies heavily on the child_process.spawn() command and take note, this doesn't block the event loop in any way. If you wanted to run shell commands in between Node js operations, then you can spawn a child process and use the exec command. I see people do this a lot: import { execSync } from 'child_process'; Take note, that execSync will block the event loop. Although, it is very good for automating shell scripts. You could also fork a child, (child_process.fork()), which will create a communication channel between them both i.e parent and child. ======= I hope I have been of service to you. Cheers. p.s.: contact me and I can schedule a mock interview for you. |
Re: Child Threads Handled In Node.js by Nobody: 10:01am On Jan 30, 2020 |
makavele:I will love to take you up on this offer in a couple of months |
Re: Child Threads Handled In Node.js by makavele: 3:20pm On Jan 30, 2020 |
crownedrookie: You're welcome in advance 1 Like |
Re: Child Threads Handled In Node.js by Nobody: 6:20pm On Jan 30, 2020 |
makavele:What kind of work are you into currently if I may ask bro |
Re: Child Threads Handled In Node.js by makavele: 6:49pm On Jan 30, 2020 |
crownedrookie: Software Engineering :: Technical Lead |
Re: Child Threads Handled In Node.js by peterincredible: 10:16pm On Jan 30, 2020 |
makavele:i sent a message to u on watsapp |
Re: Child Threads Handled In Node.js by makavele: 10:32pm On Jan 30, 2020 |
^ Whatsapp ke?? I sent you a PM . . check your Nairaland associated email . . |
Re: Child Threads Handled In Node.js by rohanjoshi0894: 9:12am On Jan 31, 2020 |
Arjunkumar09: Node.js, in its essence, is a single thread process. It does not expose child threads and thread management methods to the developer. Technically, Node.js does spawn child threads for certain tasks such as asynchronous I/O, but these run behind the scenes and do not execute any application JavaScript code, nor block the main event loop. If threading support is desired in a Node.js application, there are tools available to enable it, such as the ChildProcess module. Also, here we have listed node.js interview questions: Question: Explain the basics of Node.js. Question: How are ‘Child Threads’ handled in Node.js? Question: State some differences between Angular JS and Node.js. Question: State the primary uses of Node.js. Question: What is Event-Driven programming? Question: In the context of Node.js, what is REPL? Question: What is a test pyramid in Node.js? Question: What is libuv? Question: Is Node.js the best platform for CPU-heavy applications? Question: What is the purpose of the Express JS Package? Question: What are LTS versions of Node.js? Question: Explain the working of assert in Node.js Question: What is callback hell? Question: What is stub in Node.js? Question: What is Event Loop? Question: What is stream in Node.js? What are its types? Question: List and explain the timing features of Node.js. Question: Highlight the differences between process.nextTick() and setImmediate(). Question: Explain readFile and createReadStream in Node.js. Question: Does Node.js provide a Debugger? Question: Describe the exit codes in Node.js. Question: Why is NODE_ENV used? Question: What is Event Emitter in Node.js? Question: What is Punycode? Question: Explain the concept of JIT and highlight its relation with Node.js. Question: Why is the buffer class used in Node.js? Question: What is the difference between fork () and spawn () methods in Node.js? Question: State the steps to write an Express JS application. To get the answer to these questions you can [url="https://hackr.io/blog/node-js-interview-questions"]follow us[/url]. |
Re: Child Threads Handled In Node.js by rubygem: 9:19am On Jan 31, 2020 |
The os and cluster core module can also handle child processes.However, unlike the core child-process module, the child process can't communicate with the parent process. Here is how it is implemented: var cluster = require('cluster'); var numCPUs = require('os').cpus().length; if (cluster.isMaster) { console.log('I am the master/parent process launching workers!'); for(var i = 0; i < numCPUs; i++) {cluster.fork();} } else { console.log('I am a fork/child process'); //perform child operations } |
Re: Child Threads Handled In Node.js by makavele: 10:53am On Jan 31, 2020 |
@rohanjoshi0894 Stop pasting google answers. Show that you really know nothing about the subject in question.
|
(1) (Reply)
Visual Game Programmer Needed / Salesforce Online Training And Certification / Image Data Collection Gig
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 28 |