wood burning stoves 2.0
The moose likes Java in General and the fly likes Java Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Timer" Watch "Java Timer" New topic

Java Timer

Sanjit Singh

Joined: Nov 12, 2001
Posts: 27
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.
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Conversation on Timer threads. There are lots of these conversations in the Threads forum.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://aspose.com/file-tools
subject: Java Timer
It's not a secret anymore!