Hello,
I was reading the code of reactjs and it uses fibers to process the virtual dom. And I found that fibers are green threads i.e. they are like threads but not actually backed by OS or hardware threads by default. I feel like they are pretending to be threads but are actually run sequentially?
So, then if there is only one OS thread that will be executing N fibers, then how does it make sense that the program broken down to execute in those N fibers will be faster than the program that just runs in a straight line from beginning to end? I'm not getting how it can become faster.
I'm imagining that I have only one actual thing that runs code. Then I'm splitting the code I need to run so different parts of it run out of sequence with each other, but still they are all run by that same underlying singular thing that can run code. And that one thing can only run things one by one, even if I ask it to run out of sequence things. So, then how can the end result become faster?