Using ThreadPoolExecutor and AsyncTask

When using ThreadPoolExecutor can I use AsyncTask as Runnable in my queue? Or does it defeat the goal?

//A holder for various tasks
private final LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(5);

//Thread Pool Executor
private final ThreadPoolExecutor tpe = new ThreadPoolExecutor(3, 3, 10, TimeUnit.SECONDS, queue);
+3
source share
2 answers

AsyncTask is not Runnable, so you cannot use it.

+6
source

Here is a good approach if you need to manage your own task more individually. Use queues and executors, pass executables, or related ones. http://ugiagonzalez.com/2012/07/02/theres-life-after-asynctasks-in-android/

0
source

Source: https://habr.com/ru/post/1732535/


All Articles