You asked:
How does the code in the main thread and its runloop interact?
The main runloop is just a loop that runs in the main thread.
What if our code runs for so long that runloop cannot run?
If you block the main thread (i.e. you do something synchronously, which is very slow), then the runloop that called your code and is waiting for your return will not be able to continue the loop, and therefore it all depends on what (timers, sources, user interface, etc.) will be frozen.
, - , , - , , , , . , , , runloop .
, , runloop, -. , runloop "", . , runloop , (, , ..) ( , runloop, , runloop).