java通过pid来kill进程
近段工作用到了线程方面的东西,拿出一些来和大家进行分享下,这里主要是通过pid来kill进程,以下是方法public void killByPid(String str) {
final String[] Array = { "ntsd.exe", "-c", "q", "-p", str };
int i = 0;
try {
Process process = Runtime.getRuntime().exec(Array);
process.waitFor();
} catch (InterruptedException e) {
System.out.println("run err!");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (i != 0) {
try {
Process process = Runtime.getRuntime().exec(Array);
process.waitFor();
} catch (InterruptedException e) {
System.out.println("err!");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
补充:软件开发 , Java ,