Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:39:36+00:00 2026-05-24T11:39:36+00:00

Is it possible that some calls publishProgress missed by onProgressUpdate? I mean is it

  • 0

Is it possible that some calls publishProgress missed by onProgressUpdate? I mean is it possible there may be one transfer miss between doInBackground and onProgressUpdate callbacks with using publishProgress call. Because I see that.

class DoSomething extends AsyncTask Void, String, Void {
  String[] S = new String[] {"a", "b", "c", "d"};

  void doInBackground(Void... ps) {

    for(String s : S) {      
      publishProgress(s);
    }
   }

  void onProgressUpdate(String... vs) {

   Log.d("", vs[0]);
 }

What i am encountering that resulting

a b b d

what happening to c?
Note: This is just illustration of my application, and this happens sometimes(not at all run), i could not write all the codes here because its too complicated. But in summary this is happening.
So any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:39:37+00:00Added an answer on May 24, 2026 at 11:39 am

    Ok. I dug deep and found the answer that: message transmission between doInBackground and onProgressUpdate is not serial that is asynchronous (from the base class name). Any call in doInBackground with publishProgress(xx) will eventually reach to onProgressUpdate but not one-to-one.
    For example, very dummy demonstration:

    doInBackgroud() {
    String s;
     for(i=1 to 10) {
       s = i.toString();
       publishProgress(s);
      }
    }
    
    onProgressUpdate(String par) {
    Log.d(par);
    }
    

    can be result as: 1 2 2 3 4 5 5 5 6 7
    What tha ?
    Dont worry, we sending the local variable s (in doinback.) by reference and by the time onProgressUpdate invoked and it is logging its value, there is probability that doInBackground is changing the value of s. That results unexpected value in the onProgressUpdate. But all publishProgress calls invoke the onProgressUpdate method.
    If we wrote:

    doInBackgroud() {
    
     for(i=1 to 10) {
      String s = i.toString();
       publishProgress(s);
      }
    }
    
    onProgressUpdate(String par) {
    Log.d(par);
    }
    

    this time under normal conditions, result must be : 1 2 3 4 5 6 7 8 9 10
    and this is what we expect, isn’t it?
    if there is better idea, i would like to hear that
    And any comments will be well-welcomed.
    Note: Maybe too simple case, but saved my week.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I'm inside a destructor is it possible that some other thread will start
I have some sql statements that calculates some numbers. It's possible (with bonus points/penalty
Question So I've recently came up with some new possible projects that would have
Is it possible make some handler that will do something when user shutdown computer
I am working with some input that is in the possible forms $1,200 20
Is it possible to use a DB sequence for some column that is not
Possible Duplicate: Avoiding repeated constants in CSS We have some theme colors that are
Possible Duplicate: String vs StringBuilder I just revisited some of the books that I
I'm looking for some kind of a resource (website) that would list all possible
Is this possible? Situation is that I want to store some XML in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.