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 8497417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:07:12+00:00 2026-06-11T00:07:12+00:00

I have an Response object for representing an post response to a web service.

  • 0

I have an Responseobject for representing an post response to a web service. Given this code:

Response resp1= Server.request(a);
Response resp2= Server.request(b);
Response resp3= Server.request(c);
if (resp1.isOk() && resp2.isOk() && resp3.isOk()){
    // Do stuff
}

Since the server is a little slow I’d like to parallelize the petitions in 3 threads. But I’m don’t know how to make the main thread to wait for the result and retrieve the 3 responses.

  • 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-06-11T00:07:14+00:00Added an answer on June 11, 2026 at 12:07 am

    I guess you could do something like that to launch the calls in 3 threads and wait for their termination:

    private Response resp1, resp2, resp3;
    
    protected void doRequests() {
        Thread thread1 = new Thread() {
            public void run() {
                resp1= Server.request(a);           
            }
        };
        Thread thread2 = new Thread() {
            public void run() {
                resp1= Server.request(a);           
            }
        };
        Thread thread3 = new Thread() {
            public void run() {
                resp1= Server.request(a);           
            }
        };
    
        thread1.start();
        thread2.start();
        thread3.start();
    
        try { thread1.join(); } catch(InterruptedException e) { }
        try { thread2.join(); } catch(InterruptedException e) { }
        try { thread3.join(); } catch(InterruptedException e) { }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an HttpResponse object for a web request I just made. The response
I have response stream from a ftp web request that returns binary file. I
Should you make one request/response object for each method or should you have one
I have created a REST web service using WCF and use HTTP Post Method.
I have a small app which query our SharePoint server' Web Service interface for
I have the following JSON object: { response: { status: 200 }, messages: [
I have a service interface with many methods, all of which take a Request
Let's say I have a Django response object. I want to find the URL
I have an io.ReadCloser object (from an http.Response object). What's the most efficient way
I'm receiving a JSON response from a web service, but for various reasons I

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.