android app crashes when exceeded Thread pool 9 and queued tasks 128

妖精的绣舞 提交于 2019-12-01 10:45:27

queued tasks = 128 indicates that you have reached maximum count of tasks for AsyncTask:

private static final BlockingQueue sPoolWorkQueue = new LinkedBlockingQueue(128);

one aproach is to queue your jobs in some data structure, in example bundles and store it in some database (sqlite). It would be usefull anyway because if user will terminate your application, then now all your tasks are lost. If they are persisted in sqlite - then you can send them on next app run.

You could also use Executors.newSingleThreadExecutor, which has unbounded queue, but you would have to do any UI updates yourself - in example with handlers. AsyncTask-s implementation is based on Executors.

From what I understood about AsyncTask, AsyncTask implementation before kitkat can queue only 128 tasks. Above which it will issue RejectedExecutionException. So I would suggest you reduce the number of AsyncTask created.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!