Android 的消息机制(4)
上面的文章我们演示了如何把一个Message由子线程发送给主线程,但是如何将一个Message从主线程发送给子线程呢?子线程在默认的情况下是没有Looper的,也就没有可能操作子线程的消息队列。我们通过查API文档可以看到: Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped. Most interaction with a message loop is through the Handler class. 大概意思是,线程在默认情况下是没有Looper的,但是可以通过调用Prepare()方法来运行一个loop,然后使用loop()方...