Android AsyncTask not invoked within minutes on ICS

I have an application that uses a lot of AsyncTasks, the problem is that a particularly important task does not start within a couple of minutes after the execute call.

If I use the following for my ICS devices, this works:

if(Build.VERSION.SDK_INT >= 11) { myTask.executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR, stuff ); } 

in contrast to pre-ICS;

 myTask.execute(stuff); 

I know that ICS changed the execution of a thread to be serialized, but I cannot figure out what the thread queue is holding.

There are about 20 threads in eclipse, but I read about it, maybe this is wrong, since the debugger tends to keep the ones actually displayed.

How can I determine which threads support the serialized queue, so I don’t need to switch from default to ICS and maybe even improve the performance of devices to ICS that do not see problems because the thread pool executor is the default behavior.

+4
source share
1 answer

How to determine which threads support a serialized queue

Add Log statements to track input and output from the corresponding doInBackground() methods.

and possibly even improve the performance of devices to ICS that do not see problems due to the thread pool executor being the default behavior.

You do not need to use AsyncTask . Just mark up your thread and use stuff like runOnUiThread() as a means of executing logic in the main thread of the application. AsyncTask is a convenience, not a requirement. And for a higher priority task, which may have a higher priority, it might be wiser for you to just leave this aside from any thread pool conflict.

Or, the AsyncTask clone and fork use PriorityQueue , so you can explicitly specify your high priority tasks.

+3
source

All Articles