What is the real point and advantage of having a run loop?

When reading Apple docs on multithreading, they talk a lot about Run Loops. What's the point of creating a run loop? Is it for reusing a user thread multiple times? In what example situations is Run Run Loop a good idea?

How does this run loop relate to the thread? Let's take an example of the main launch cycle of an iPhone OS application. When the user touches the screen, he fires an event. Does the loop loop reuse the main thread to handle the event with some code? Or does a loop loop create a new thread every time an event occurs?

+3
source share
3 answers

- , .

, , .. , .

:

while( !quit ) {
    // Handle events
    // Listen for input
    // Manage timers
    // ...

}

, . , , .

, . . , , , , , .

Apple developer.apple.com.

+3

- , , . I.e, - DOS.

Windows Cocoa .NET REALbasic , . , , . , . , .

. Cocoa . , .

iPhone Cocoa , . , , , .

+7

Runloops. , - . , . , , . iKenndac, , , , DOS. Swing SWT J2ME Blackberry iPhone . . . RunLoops . , , , RunLoop. , CocoaTouch SDK, .

+1
source

Source: https://habr.com/ru/post/1720677/


All Articles