1.子线程创建handler 方法一 HandlerThread handlerThread = new HandlerThread(" sub thread name"); //主要解决线程同步问题 handlerThread.start(); Handler subHandler = new Handler(handlerThread.getLooper()){ public void handleMessage(){ // 这里就是子线程,子线程名字为 sub thread n…
最经面试中,技术面试中有一个是Handler的消息机制,细细想想,我经常用到的Handler无非是在主线程(或者说Activity)新建一个Handler对象,另外一个Thread是异步加载数据,同时当他加载完数据后就send到主线程中的那个Handler对象,接着Handler来处理,刚才发送的一些消息. public class HandlerTestActivity extends Activity { private TextView tv; private static final i…
1.Handler是什么? 原文: A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue. When you create a new Handler,…