Android handler transmits messages. androidhandler

Source: Internet
Author: User

Android handler transmits messages. androidhandler

When a worker thread sends a message to the main thread, because the main thread has logoff, it does not need to initialize logoff. Pay attention to the handler associated with the sender of the message, in this case, handler of the main thread is used.

Handler will send messages to the MessageQueue queue, and logoff will continuously traverse the MessageQueue queue. When there is a message, the handleMessage method of handler will be called back!

When the main thread sends a message to the working thread, it is associated with the handler of the sub-thread, and the sub-thread does not have logoff. Therefore, we need to call lorule. prepare (), initialize a lorule, and put it in Threadlocal,

Finally, call the logoff. loop Method to start polling messages in the MessageQueue queue. The mechanism is also a callback mechanism!

Related Article

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.