[AndroidThread&Handler]Thread1-实现方法
扩展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 "); } }; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。