The standard way involves java.lang.Process, but you cannot use that directly.
The Process instance is created by java.lang.ProcessBuilder, which can be invoked directly or (more common, I think) via one of the java.lang.Runtime.exec(...) overloads.
You mean, you need to run a given command several times -- start several subprocesses ? For that, ProcessBuilder is the best choice. It creates a Process instance that you can start() as many times as you need and it will generate a new subprocess every time with the same command, environment etc.
UPDATE: sorry, it's not the process that you reuse, it's the builder itself: each call to start() creates a new Process with the same command, env...
but we are doing same thing by using waitFor() from different thread...
I want to implement timeout concept for waitFor() as if that method fails then one should recover it.
Than you could start an extra thread that simply sleep()s for an amount of time and then checks if the Process is still running, and destroy()s it if so. Or a combination of Process.waitFor(), Thread.sleep(), Thread.interrupt() in two separate threads.
Well, you don't need to spawn two threads for each created process. Actually, I think you can reduce it all to only one extra thread that monitors all the spawned processes in a clever way and kills them if they've lasted for too long.