Android AsyncTask threads never die
http://www.drovik.com/ 2013-6-7 11:34:12 来源:www.drovik.com 点击:
I'm new to Android programming and I'm using AsyncTasks to fetch data in response to the user pressing a button. This works well and keeps the interface responsive while fetching the data, but when I checked out what was going on in the Eclipse debugger, I found out that every time a new AsyncTask was created (which is quite often, because they can only be used once), a new thread was being created but never terminated. The result is a large number of AsyncTask threads just sitting there. I'm not sure if this is a problem in practice or not, but I'd really like to get rid of those extra threads. How can I kill these threads?
AsyncTask manages a thread pool, created withThreadPoolExecutor. It will have from 5 to 128 threads. If there are more than 5 threads, those extra threads will stick around for at most 10 seconds before being removed. (note: these figures are for the presently-visible open source code and vary by Android release).
Leave the AsyncTask threads alone, please.
- 相关文章
- android app中使用JNI (2人浏览)
- Android模拟器下的NDK运行opengl的问题 (9人浏览)
- 期待解决Android OpenGL ES显示yuv时 glTexSubImag (102人浏览)
- 最新Android面试题整理 (14人浏览)
- 最新Android面试题整理 (30人浏览)
- Android利用GPU高清视频播放的分析 (31人浏览)
- 编译Android源码和Linux内核源码时候遇到的一些错误 (4人浏览)
发表评论(0)