mirror of
https://github.com/xfarrow/javascript-tutorials.git
synced 2025-04-20 05:17:25 +02:00
Update README.md
This commit is contained in:
parent
751c6919fe
commit
62b993e2c1
@ -4,10 +4,12 @@ JavaScript is single-threaded but it can still take advantage of asynchronous
|
|||||||
programming.
|
programming.
|
||||||
|
|
||||||
When we say JavaScript is single-threaded, we mean that we cannot write
|
When we say JavaScript is single-threaded, we mean that we cannot write
|
||||||
multithread code without using JavaScript APIs. In fact,
|
multithread/concurrent code without using JavaScript APIs. In fact,
|
||||||
despite for us it appears single-threaded, it takes advantage of the
|
despite for us it appears single-threaded, it takes advantage of the
|
||||||
`libuv` library, allowing the engine to be effectively multithread.
|
`libuv` library, allowing the engine to be effectively multithread.
|
||||||
|
|
||||||
|
Another way to put it is that we have one and only one Call Stack.
|
||||||
|
|
||||||
In order to do that, JavaScript uses
|
In order to do that, JavaScript uses
|
||||||
* The libuv APIs which allow multithreading
|
* The libuv APIs which allow multithreading
|
||||||
* The Event Loop Queue
|
* The Event Loop Queue
|
||||||
@ -43,3 +45,8 @@ When 1000ms have elapsed, the callback function associated with the timer (conso
|
|||||||
gets enqueued in the Queue.
|
gets enqueued in the Queue.
|
||||||
Since there is nothing to do in the stack, the callback pushes the callback onto the
|
Since there is nothing to do in the stack, the callback pushes the callback onto the
|
||||||
stack and executes it.
|
stack and executes it.
|
||||||
|
|
||||||
|
## Useful resources
|
||||||
|
* https://www.youtube.com/watch?v=lqLSNG_79lI
|
||||||
|
* https://dev.to/lydiahallie/javascript-visualized-event-loop-3dif
|
||||||
|
* https://www.youtube.com/watch?v=eiC58R16hb8
|
Loading…
x
Reference in New Issue
Block a user