// 发送消息给子线程
Message childMsg = child1.childHander.obtainMessage();
Message msg = new Message();
msg.obj = mMainHandler.getLooper().getThread().getName()
+ " says Hello and msbBtn sending";
child1.childHander.sendMessage(msg);
Log.i(TAG, "Send a message to the child thread - "
+ (String) msg.obj);
}
}
});
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (child2.childHander != null) {
// 发送消息给子线程
Message childMsg = child2.childHander.obtainMessage();
Message msg = new Message();
msg.obj = mMainHandler.getLooper().getThread().getName()
+ " says Hello and btn1 sending";
child2.childHander.sendMessage(msg);
Log.i(TAG, "Send a message to the child thread - "
+ (String) msg.obj);
}
}
});
}
public void onDestroy() {
super.onDestroy();
Log.i(TAG, "Stop looping the child thread's message queue");
if (child1.childHander != null) {
child1.childHander.getLooper().quit();
}
if (child2.childHander != null) {
child2.childHander.getLooper().quit();
}
}
}