01 / 12
Why it looks simultaneous
You type node main.js in the terminal. Behind it the browser is painting a page, music is playing and your editor is running.
But there is one CPU, and one CPU can execute only one instruction at any given instant. Looking simultaneous is not the same as being simultaneous.
What is happening is rapid alternation. Advance your program a little, stop; advance the browser a little, stop; advance the music a little. That switching happens hundreds of times a second, so to human eyes it looks simultaneous.
This way of cramming several programs onto one CPU and alternating between them is multiprogramming (multitasking). This whole lesson is about how that alternation is arranged.
there is one CPU[A][B][A][B][A][B] ^ short slices, alternatingit looks simultaneous to us