dcsimg
Java TIMER
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sanjit_Singh
Posted On:   Monday, November 25, 2002 05:23 AM

Hi Everyone, I have a JAVA client that sometimes hangs up waiting for a response from the server. The basic code where it hangs is as follows: ******** BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); ******** where con is an object of the HttpURLConnection class. I would like to avoid this somehow. I would like the thread to only wait for 10 seconds on this particular line (only on this line) and if a response still doesn´t come, then exception occurs. I can imagine that I have to use the Timer class. Any help in this regard (sample code, ideas) would be highly appreciated. Thanks!    More>>

Hi Everyone,



I have a JAVA client that sometimes hangs up waiting for a response from the server.

The basic code where it hangs is as follows:

********

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
********

where con is an object of the HttpURLConnection class.
I would like to avoid this somehow. I would like the thread to only wait for 10 seconds on this particular line (only on this line) and if a response still doesn´t come, then exception occurs.


I can imagine that I have to use the Timer class. Any help in this regard (sample code, ideas) would be highly appreciated.
Thanks!

   <<Less
About | Sitemap | Contact