You are viewing a single comment's thread from:

RE: JS: Advanced Fundamentals. Async Series: Callbacks (part 1)

in #javascript8 years ago

Sorry for late response (sleep, job).
JavaScript is single threaded, there is no way in the language to manage threads. You can spinn up a lot of JS/Node processes though, but as a programmer you can manage only one.

Heavy calculations and graphics will be syncronous. You can simulate heavy calculation by running for in loop billion times. If you do it in browser, you will find, that it freezes your window for a couple of seconds. I'll try to illustrate it in later post. Good call!

Modern browsers spinn up multiple instanses for faster perfomanse. You can do it yourself with Node. But this instances have limited abylity to communicate to each other. Script you write will only be executed in one thread.

Threads is an instrument to solve concurrency problem in programming, JavaScript solved concurrency by build in async. There mechanism under the hood called Event Loop, it some sort of the queue, which Javascript uses to know when to run your callback.

Sort:  

Thank you! It was very informative,
I am programming usually on perl and my knowledge about javascript is tiny, only base syntax and jquery.