Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ThreadPoolExecutor and AsyncTask

Tags:

java

android

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

//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);
like image 421
jax Avatar asked Jun 16 '26 08:06

jax


1 Answers

An AsyncTask is not a Runnable so you can't really use that.

like image 176
Moritz Avatar answered Jun 18 '26 21:06

Moritz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!