java实现终止javaw.exe线程
public static void main(String[] args) throws IOException { Process process = Runtime.getRuntime().exec("cmd.exe /c tasklist |findstr \"javaw\""); Scanner in = new Scanner(process.getInputStream()); while (in.hasNextLine()) { String p = in.nextLine(); System.out.println(p); if (p.indexOf("javaw.exe") != -1) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < p.length(); i++) { char ch = p.charAt(i); if (ch != ' ') { buf.append(ch); } } // 打印 javaw.exe的pid String pid = buf.toString().split("Console")[0].substring("javaw.exe".length()); // Runtime.getRuntime().exec("cmd.exe /c tskill " + pid); Runtime.getRuntime().exec("ntsd -c q -p 1528" + pid); } } }