What change did really Android team make in Async task after android 2.3. When I executed the following code I am getting same result in both Android 2.3 and 3.0.
The change in the AsyncTask behavior also requires you run on ICS and above hardware.
See: http://commonsware.com/blog/2012/04/20/asynctask-threading-regression-confirmed.html
This thread outlines the changes to AsyncTask in ICS. The information is provided by a Google Employee, so it's trustworthy.
https://groups.google.com/forum/?fromgroups#!topic/android-developers/8M0RTFfO7-M
Your assumptions is correct, well, sort of.
The default executor inside android.os.AsyncTask:
... ...
private static volatile Executor sDefaultExecutor = SERIAL_EXECUTOR;
... ...
has been reset in android.app.ActivityThread:
... ...
// If the app is Honeycomb MR1 or earlier, switch its AsyncTask
// implementation to use the pool executor. Normally, we use the
// serialized executor as the default. This has to happen in the
// main thread so the main looper is set right.
if (data.appInfo.targetSdkVersion <= android.os.Build.VERSION_CODES.HONEYCOMB_MR1) {
AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
... ...
Check out AsyncTask change history, more specifically, this one:
Mar 17, 2011 - AsyncTask now uses the poll executor for apps up through HC MR1 and t…
This is a factor of total number of tasks and execution time per each task, in another world, the total task number is 140 (which is bigger that 128), however, the total number of thread allocated by threadpool at any given time is smaller than 128, in another word, there are always some idle threads (due to last task finished and release resource) available in your case. you can try increase the execution time per each task for example Thread.sleep(10000)
, this will probably give you RejectedExecutionException.