Runtime rt = Runtime.getRuntime();
Process process = rt.exec("...");
process.waitFor();

解决方案 »

  1.   

    waitFor()方法会等待子线程结束后再返回,主线程才继续执行。
      

  2.   

    用process.waitFor();等待子进程结束才继续父进程的运行。
      

  3.   

    回to totodo(土豆仙):
    那用什么呢?
    2004-09-02 22:27:00 totodo(土豆仙)在他的大作中提到:
     >
     >建议不要用这些代码..
     >
      

  4.   

    Runtime rt = Runtime.getRuntime();
    Process process = rt.exec("...");
    process.waitFor();//此处process应该是代表子进程,也就是rt.exec("...");的进程
    它并不是父进程,调用它的waitFor()方法难道是等待它本身执行完成吗?