Android : correct way to queue and canceling asynctasks

on Wednesday, September 24, 2014


Can anyone help in solving such problem. I have a gridView, wich contains about 300 elements. Each element has an imageView. When getView() is called, starts async image loader, which first looks for image in LruCache, then in external storage, and then in the net. Async tasks starts via executeOnExecutor with parameter AsyncTask.THREAD_POOL_EXECUTOR. Abd the problem is if scroll grid view too fast, creatrs a lot of threads and app crashes with E/AndroidRuntime(14980): java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@42426f98 rejected from java.util.concurrent.ThreadPoolExecutor@41c6c800[Running, pool size = 128, active threads = 128, queued tasks = 10, completed tasks = 3] Can anyone advice some method to control the amount of tasks to avoid such exceptions. Thank you.


0 comments:

Post a Comment