IntentService 新建线程的证明

       在Activity中,startService()创建IntentService的时候,通过打印线程id,得知当前线程是1//  long id = Thread.currentThread().getId();

       在IntentService的默认构造函数中,打印线程id 仍然为1

       在onHandleIntent()中打印id,发现id为96,说明在onHandleIntent()处理事件的时候,系统会自动开辟新的线程去处理,这就是IntentService的用处,

     All requests are handled on a single worker thread -- they may take as long as necessary (and will not block the application's main loop), but only one request will be processed at a time.

      所有的请求都在一个单独的工作线程里执行,所有的请求都必须等待上一线程执行完毕,无论这一等待时长需要多久。

posted on 2014-02-18 17:53  小白说我是2B  阅读(352)  评论(0编辑  收藏  举报

导航