how to get http responses continuously to a java application?
Posted
by
senrulz
on Stack Overflow
See other posts from Stack Overflow
or by senrulz
Published on 2012-10-21T04:43:13Z
Indexed on
2012/10/21
5:01 UTC
Read the original article
Hit count: 121
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 :)
© Stack Overflow or respective owner