Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Timer

 
Sanjit Singh
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Conversation on Timer threads. There are lots of these conversations in the Threads forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic