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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:38:02+00:00 2026-06-13T03:38:02+00:00

I have the coding shown below where I have sheduled to get a http

  • 0

I have the coding shown below where I have sheduled to get a http response from a php web server page.

public static void stopPHPDataChecker() {      
        canStop=true;
}

public static void main (String args[]) {
    // http request to the php page and get the response
    PHPDataChecker pdc = new PHPDataChecker();
    ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
    final ScheduledFuture<?> pdcHandle = scheduler.scheduleAtFixedRate(pdc, 0L, 10L, TimeUnit.MILLISECONDS);// Start schedule
    scheduler.schedule(new Runnable() {

        public void run() {
            System.out.println(">> TRY TO STOP!!!");
            pdcHandle.cancel(true);
            Sheduler.stopPHPDataChecker();
            System.out.println("DONE");
        }

    }, 1L, TimeUnit.MILLISECONDS);

   do {
        if (canStop) {
            scheduler.shutdown();

        }
    } while (!canStop);

    System.out.println("END");
}

this coding only returns one response but I want it to get responses continuously so i can do different tasks according to the returned value. how can i do it?
Thank you in advance 🙂

  • 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-13T03:38:04+00:00Added an answer on June 13, 2026 at 3:38 am

    – My simple suggestion will be using Thread, which will send a request to the webservice after a regular interval of time, and receive the response.

        Thread t = new Thread(new Runnable(){
    
              public void run(){
    
       while(isDone){  
    
                 //isDone is the boolean variable which will help u end the Thread.
    
                // SEND THE REQUEST 
    
    try{
    
      Thread.sleep(5000);   // Delay of 5 seconds before the request is fired again
    
       }catch(Exception ex){
    
               ex.printStackTrace();
    
            }
        }
       }
    
        });
    
     t.start();
    
     t.join();   // Use join() to block the process further till the response arrives.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using the coding shown below i have managed to retrive data from a sql
Previously i have used restful wcf webservices to get the data from server.But now
I have problem. The coding is shown as below. When I run the program
I’m new to web development but have coding experience (Java) and I’m trying to
We have a coding standard that says all shared (static) fields and methods must
I am developing RESTful with php. Currently I have started coding with MVC design
Ive never heard of this before, and I have been coding in PHP for
I have the below coding, i am make sure that if condition is TRUE,
Hi people I have the following code (shown below) and I am trying to
I have couple of forms on my php page. I am using jQuery (&

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.