This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Author

end waiting for message (timer class?)

Joel Carklin
Greenhorn

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.
Thanks
Joel
Jason Menard
Sheriff

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:

HTH
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: end waiting for message (timer class?)
 
It's not a secret anymore!