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

  • Home
  • SEARCH
  • 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 7574513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:27:12+00:00 2026-05-30T16:27:12+00:00

I want to execute the method uploadingDone() after completion of all three threads. The

  • 0

I want to execute the method uploadingDone() after completion of all three threads.
The flags are working most of time correct. In rare case all three flags set to true and BLOCK1 get executed twice. All three threads are doing different tasks on different data ( No Concurrent modification can occur).

Can I eliminate the flags with any native function on thread?

All three threads to be run in parallel(Mandatory Requirement.).
BLOCK1 should be called only once.

private synchronized void uploadingDone(){

    if( isItemUploaded && isListUploaded && isStoreUploaded){
        uploadingDone = true;
         //<BLOCK1>
        //TODO move to next screen
    }else{
        Log.i(TAG, "uploadingDone: Failed");
    }
}

private boolean isListUploaded = false, isItemUploaded = false, isStoreUploaded = false, uploadingDone = false;


private class ListUpload extends Thread{

    @Override
    public void run() {
        isListUploaded = true;
        Log.i(TAG, "ListUpload Thread started");
        if(!uploadingDone)
            uploadingDone();
    }

}

private class ItemUpload extends Thread{

    @Override
    public void run() {
        Log.i(TAG, "ItemUpload Thread started");
        isItemUploaded = true;
        if(!uploadingDone)
            uploadingDone();
    }
}

private class StoreUpload extends Thread{

    @Override
    public void run() {
        Log.i(TAG, "StoreUpload Thread started");
        isStoreUploaded = true;
        if(!uploadingDone)
            uploadingDone();
    }

}

private ListUpload listUpload;
private StoreUpload storeUpload;
private ItemUpload itemUpload;

public void startUpload(){

    listUpload = new ListUpload();
    listUpload.start();

    storeUpload = new StoreUpload();
    storeUpload.start();

    itemUpload = new ItemUpload();
    itemUpload.start();

}

Thank you.

  • 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-30T16:27:14+00:00Added an answer on May 30, 2026 at 4:27 pm

    Skip the flags and add

    listUpload.join();
    storeUpload.join();
    itemUpload.join();
    // <BLOCK1>
    

    at the end of startUpload(). Each call to join() will cause the calling thread to block until the given thread finishes.

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

Sidebar

Related Questions

I want execute below callback() method after completion of document.getElementById('btnDownload').click(); method . Now callback()
I'm testing a page with Selenium IDE and want to execute a method already
I want to create a list of methods to execute. Each method has the
I want to execute a function on all the objects within a List of
I want to execute a method on VB.Net to return a date which is
The scenario I have, is in the Execute method of a SPJobDefinition I want
I only want to execute a method call when the user clicks on a
I've the following model and I want to execute a method on save and
I want to execute a static method from certain class in certain namespace, but
I have a method which returns a bool value. I want to execute that

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.