扩展Thread的示例代码:
public class CommonTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new Thread(){ public void run(){ System.out.println("Thread is running."); } }.start(); } }
使用Runnable的示例代码:
public class CommonTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new Thread(r).start(); } Runnable r = new Runnable() { @Override public void run() { System.out.println("Runnable running "); } }; }
[AndroidThread&Handler]Thread1-实现方法,布布扣,bubuko.com
[AndroidThread&Handler]Thread1-实现方法
原文地址:http://www.cnblogs.com/webapplee/p/3774031.html