Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

end waiting for message (timer class?)

 
Joel Carklin
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic