24 handle

时间:2014-05-03 22:54:20   收藏:0   阅读:332

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放入主线程,没有开辟新线程。

 

  

24 handle,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!