24 handle

1 http://blog.csdn.net/dengxiayehu/article/details/6398648

       Handler mHandler = new Handler();

  1. Runnable workRunnable = new Runnable() {  
  2.         int counter = 0;  
  3.           
  4.         public void run() {  
  5.             if (counter++ < 1) {  
  6.                 Log.i(TAG, "workRunnable thread id = " +   
  7.                         Thread.currentThread().getId());  
  8.                 mHandler.postDelayed(workRunnable, DELAY_TIME);  
  9.             }  
  10.         }  

mHandler.postDelayed(workRunnable, DELAY_TIME); 

 mHandler.removeCallbacks(workRunnable);

handler将thread放入主线程,没有开辟新线程。

 

  

posted @ 2014-05-03 15:20  阿黄的苹果  阅读(87)  评论(0编辑  收藏  举报