File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes end waiting for message (timer class?) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "end waiting for message (timer class?)" Watch "end waiting for message (timer class?)" New topic

end waiting for message (timer class?)

Joel Carklin

Joined: Jun 15, 2001
Posts: 28
Hi All,
My situation is this:
I send an xml message to another server and then expect a reply xml message. I need to set a timeout so that if the I don't get a response mesaage after say 5 seconds then my method will return null, rather than continuing to wait for the response.
I looked at the java util Timer class, but it confused me in this particular scenario.
Any help / suggestions appreciated.
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
If you don't need to spawn another thread and if you do not need a timer that is precise to the millisecond, you could do something simple like the following:

I agree. Here's the link:
subject: end waiting for message (timer class?)
It's not a secret anymore!