1 http://blog.csdn.net/dengxiayehu/article/details/6398648
Handler mHandler = new Handler();
- Runnable workRunnable = new Runnable() {
- int counter = 0;
- public void run() {
- if (counter++ < 1) {
- Log.i(TAG, "workRunnable thread id = " +
- Thread.currentThread().getId());
- mHandler.postDelayed(workRunnable, DELAY_TIME);
- }
- }
mHandler.postDelayed(workRunnable, DELAY_TIME);
mHandler.removeCallbacks(workRunnable);
handler将thread放入主线程,没有开辟新线程。
时间: 2024-10-06 03:49:17