Transferred from: HTTP://WWW.JIANSHU.COM/P/41901FB416D6
What is Runloop?
From a literal point of view: Running loops, running laps
In fact, it is the Do-while loop, which constantly handles various tasks within the loop (such as source, Timer, Observer)
One thread corresponds to a runloop, the runloop of the main thread is started by default, the runloop of the child thread must be started manually (call the Run method)
Runloop can only select one mode to start, if there is no source, Timer, Observer in the current mode, then exit directly Runloop
When does the auto-release pool release?
Release before Runloop sleep (kcfrunloopbeforewaiting)
How do I use runloop in development? What application scenario?
Open a resident thread (let a child thread not go extinct, wait for other threads to send messages, handle other events)
Turn on a timer in a sub-thread
Perform some long-term monitoring in a child thread
IOS Interview Runloop