Moniter.java
上传用户:hainatieta
上传日期:2019-07-13
资源大小:1076k
文件大小:1k
- package cn.seejava.lei2;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class Moniter implements Runnable{
- static boolean programeOn = false;
-
- public void run() {
- // TODO Auto-generated method stub
- while(true){
- Process pro;
- try {
- pro = Runtime.getRuntime().exec("cmd /c tasklist");
- BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
- String task = "";
- boolean flag = false;
- while((task=br.readLine())!=null){
- if(task.indexOf("crossfire.exe")!=-1){
- flag = true;
- break;
- }
- }
- if(flag){
- //System.out.println("设定");
- ReadyOwner.programeOn = programeOn;
- }else{
- //System.out.println("为设定-------");
- ReadyOwner.programeOn = false;
- }
- Thread.sleep(10000);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- }
-
- }
-
- }