The Android application creates a message queue when each thread is started. The life cycle of a thread is divided into two phases: creating a message queue and entering a message loop.
Message loops are divided into: Send messages and process messages.
The Android system uses the MessageQueue, Looper, and handler three classes to implement the message processing mechanism for Android applications.
messagequeue--describing Message Queuing
looper--Creating message Queues
handler--sending messages, processing messages
Creating thread Message Queuing procedures
Call the Looper class static member function Preparemainlooper or prepare to create;
Create MessageQueue object, save in Mqueue;
MessageQueue in the process of creation, call the Nativeinit method to create a Nativemessagequeue object in the C + + layer;
Android_os_messagequeue_nativeinit method is implemented to create nativemessagequeue;
Nativemessagequeue creates a Looper object for the C + + layer during the creation process;
A pipeline is created during the Looper object creation process for the C + + layer.
Android source code-the message processing mechanism of the application