????4??Shutdown???
1 public class ShutDown {
2     public static void main(String[] args) throws Exception {
3         Configure configure = new Configure();
4         System.out.println("Shutdown Guards..");
5         for (int i = 0; i < 3; i++) {
6             Process p = Runtime.getRuntime().exec("jps -l");
7             BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
8             String line;
9             while ((line = reader.readLine()) != null) {
10                 if (line.toLowerCase().contains("Guard".toLowerCase())) {
11                     String[] strings = line.split("\s{1??}");
12                     int pid = Integer.parseInt(strings[0]);
13                     Runtime.getRuntime().exec(configure.getKillcmd() + " " + pid);
14                 }
15             }
16             p.waitFor();
17             reader.close();
18             p.destroy();
19             Thread.sleep(2000);
20         }
21         System.out.println("Guards is shutdown");
22     }
23 }
????5??GuardB??GuardA????
?????塢?????????
???????????У?guard_demo
????????????http://pan.baidu.com/s/1bn1Y6BX