IOS Runloop Face question

Source: Internet
Author: User

What is a runloop?

From the literal point of view is the operation of the cycle, in fact, the internal is the Do-while cycle, the loop within the constant processing of various tasks (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 is started manually (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

Two how do you use Runloop in the development process? What application scenario?

Open a resident thread (let a child thread not go extinct, wait for messages from other threads, handle other events)

Turn on a timer in a sub-thread

Perform some long-term monitoring in a child thread

Can control the timer to run in a specific mode

Enables certain events (behaviors, tasks) to be performed in a specific mode

You can add observer to monitor the status of the runloop, such as listening for the processing of click events (such as doing some processing before all click events)

What time does the three automatic release tank release?

Release before Runloop sleep (kcfrunloopbeforewaiting)

IOS Runloop Face question

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.