use*_*129 5 multithreading android android-asynctask
Android文档说postExecute()在UI线程上调用了AsyncTask .我的印象postExecute()是从被调用的Thread execute()调用的:我一直在后台Service中使用AsyncTask并使用自己的线程,并且在服务线程中调用了postExecute(),而不是主线程.
但是,我最近遇到了一个问题,即postEecute()根本没有被调用,而抛出异常:"在死线程上向处理程序发送消息".
具体如何:
- AsyncTask只能在主线程中使用吗?
- 如果没有,postExecute()应该调用哪个线程:总是UI线程,还是execute()调用线程?
谢谢
Rom*_*Guy 14
在创建任务实例的线程上调用AsyncTask的pre和postExecute方法.你调用execute()的地方并不重要.创建任务的线程必须是一个looper线程,实际上应始终是主线程(或UI线程).
| 归档时间: |
|
| 查看次数: |
3848 次 |
| 最近记录: |