Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 java 调用 arp -s 命令并等待进程完成以完成功能。
String command ="arp -s "+entryIpAddress+" ee-ee-ee-ee-ee-ee-ee"; Process p=Runtime.getRuntime().exec(command); p.waitFor();
但是这个过程的调用比平时花费更多的时间,有没有办法提高这个方法的性能。我无法删除 p.waitFor() 我的下一个函数取决于添加的条目。
您的代码没有显示出任何努力让该过程永远完成的迹象。你没有消耗它的输出,所以它的输出缓冲区很快就会填满,阻止进一步的进展。
为了使您自己更轻松地完成此任务,请使用ProcessBuilder.
ProcessBuilder