?
package cd.edu.app;import android.app.Activity;import android.os.Bundle;import android.os.HandlerThread;import android.os.Message;import cn.edu.subclass.MyHandler;public class AndroidThreadActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); HandlerThread handThread=new HandlerThread("app"); handThread.start(); MyHandler myHand=new MyHandler(handThread.getLooper()); Message msg=myHand.obtainMessage(); msg.sendToTarget(); System.out.println(Thread.currentThread().getName()); } }
?
?
package cn.edu.subclass;import android.os.*;public class MyHandler extends Handler{ public MyHandler(Looper loop){ super(loop); } public void handleMessage(Message message){ System.out.println(Thread.currentThread().getName()); }}?
?
?