Handler创建在Thread的成员变量中(没有在run方法中),为什么2个输出都是main线程
class MyThread extends Thread{
public Handler handler2 =new Handler(){
@Override
public void handleMessage(Message msg) {
Log.d("sss",Thread.currentThread()+"handler2");
}
};
public void run() {
Looper.prepare();
Looper.loop();
}
输出
10-16 16:15:51.290 8057-8057/com.example.administrator.myapplication D/sss: Thread[main,5,main]handler2
10-16 16:15:51.290 8057-8057/com.example.administrator.myapplication D/sss: Thread[main,5,main]handler