Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to wait n seconds for Runtime.getRuntime.exec() to execute

Status
Not open for further replies.

russland

Programmer
Joined
Jan 9, 2003
Messages
315
Location
CH
Hi,

Some system commands would halt the execution if one has not enough privileges to do so. How, can I allow my runtime to try for - let's say - 10 seconds. But if nothing is return and the command is blocked, then continue.

What's a solid approach to this?

Thanks for any hints.
 
You can use Thread.sleep to wait, but I guess you will have to check the command output, depending on what you're executing.

Cheers,
Dian
 
You should start the external program in a seperate thread, and then you may wait in the main thread for 10 s.

Maybe you can kill the separate thread, if it didn't finish from there; at least continue your work.

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top