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!