Hi,

Could there be a case where onPostExecute() is never called because 
doInBackground() is stuck in some synchronous API called within ?

I've a use case where am using AsyncTask like below (code for illustration 
only) :

BackgroundCommunicatorTask mBackgroundTaskOne = new 
BackgroundCommunicatorTask(PERFORM_API_1);
mBackgroundTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);

BackgroundCommunicatorTask mBackgroundTaskTwo = new 
BackgroundCommunicatorTask(PERFORM_API_2);
mBackgroundTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);

Is my understanding correct that when we explicitly use SERIAL_EXECUTOR, 
until one thread in the queue
is finished, the next thread won't be executed ? Which means if 
doInBackground() of the thread associated with PERFORM_API_1
is stuck for unknown reasons, then the next thread in the queue (associated 
with PERFORM_API_2) won't be scheduled right ?

I've verified that the first thread is stuck, through
if (mBackgroundTaskOne .getStatus() == AsyncTask.Status.RUNNING) {
    // control is reaching here.
}

I'm clear that for my use case I should be using SERIAL_EXECUTOR only. But 
sorry if my understanding of SERIAL_EXECUTOR itself is wrong..
Could you throw some light on how to handle such cases like above ? Use a 
timeout to kill the thread forcefully ? I tried, but cancel() on the 
AsyncTask is
not honoring my call.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to