When executing AysncTask, The following api I am using
executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,"nameofpool");
Is it possible that somehow I can set only 2 threads limit in this pool.
When executing AysncTask, The following api I am using
executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,"nameofpool");
Is it possible that somehow I can set only 2 threads limit in this pool.
The AsyncTask.THREAD_POOL_EXECUTOR is a special pool that is created for you and administrated by Android.
You can, however, create your own Executor, typically using :
Executor myExecutor = Executors.newFixedThreadPool(2);
which you can use in your AsyncTask :
executeOnExecutor(myExecutor, params);
Nota: please note that your param "nameofpool" is actually the parameter to the doInBackground method on your AsyncTask, and is not related to the Thread pool management.
You can provide your own executor:
executeOnExecutor(Executors.newFixedThreadPool(2), "nameofpool");