The message usage of Android is usually logoff. prepare () logoff. myLooper (); xxxHandler = new Handler () {handleMessage (Message msg ){...}}; logoff. loop (); At the beginning, I was confused about the situation. Based on the name, I couldn't see the two classes that have any relationships. How do I transmit messages? It's okay to know how to use it. Many people should be like me. if you are interested, just click it. logoff. prepare (); There is a sThreadLocal. set (new Looper (); here a new Looper is created and put in ThreadLocal, which is a class for thread data sharing. private Looper () {mQueue = new MessageQueue (); mRun = true; mThread = Thread. currentThread ();} transmits information about the current worker thread, and a new message queue is used to receive messages. public static Looper myLooper () {return sThreadLocal. get ();} This function returns the new logoff (); pub created above. Lic Handler (){... mlogoff = logoff. myloue (); mQueue = mloue. mQueue ;...} here, the Logoff of the current thread is assigned to Handler, Which is related. some may have questions. The above are two different statements of the class logoff. mylogoff (); how can we get the same one? Let's analyze it. There is a global static container static final ThreadLocal <loal> sThreadLocal = new ThreadLocal <loal> () in the logoff class (); go to the ThreadLocal class and check public void set (T value) {Thread currentThread = Thread. currentThread (); Values values = values (currentThread); if (values = null) {values = initializeValues (currentThread);} values. put (this, value);} set the information about the current thread here. look at the get () function; public T get () {// Optimized for the fast pa Th. Thread currentThread = Thread. currentThread (); Values values = values (currentThread); if (values! = Null) {Object [] table = values. table; int index = hash & values. mask; if (this. reference = table [index]) {return (T) table [index + 1] ;}} else {values = initializeValues (currentThread);} return (T) values. getAfterMiss (this);} returns information about the current thread. because ThreadLocal is a template container and declared as ThreadLocal <T>, it is declared as ThreadLocal <lolocal> In logoff, so T = logoff. simply translate the get () and set () above; public void set (loginvalue) {values. put (this, value);} public void lodid get () {return values. get (this);} is clear, and the relationship is like this. let's take a look. logoff. prepare () logoff. myLooper (); xxxHandler = new Handler () {handleMessage (Message msg ){...}}; logoff. loop (); equivalent to logoff. prepare () {sThreadLocal. set (currentThread, new Looper ();} Looper. mylogoff () {sThreadLocal. get (currentThread)} new Handle (){... mLooper = sThreadLocal. get (currentThread); mQueue = mloue. mQueue ;...} if the link has occurred, you can use the Message to communicate with each other.