thread.sleep(interCheckTime * 1000); } catch (Exception e) {
Thread.sleep(interCheckTime * 1000); } catch (InterruptedException ignored) {
    public void run() {        boolean needRestart = false;        Process p;        logger.log(name, "apache montior thread running");        try {            p = Runtime.getRuntime().exec(apachectlLocation + " start");        } catch (Exception e) {            e.printStackTrace();        }        logger.log(name, "httpd started");        while (getApacheState()) {            if (needRestart) {                try {                    logger.log(name, "restarting apache");                    p = Runtime.getRuntime().exec(apachectlLocation + " start");                    needRestart = false;                } catch (IOException e) {                    e.printStackTrace();                }            }             //end if (needRestart)            try {                thread.sleep(interCheckTime * 1000);            } catch (Exception e) {            }            try {                String test = null;                String shellLocation = "/bin/bash";                Process p2 = Runtime.getRuntime().exec(shellLocation);                BufferedReader pOut2 =                        new BufferedReader(new InputStreamReader(p2.                                                            getInputStream()));                DataOutputStream dos2 =                                new DataOutputStream(p2.getOutputStream());                dos2.writeBytes("ps -A | grep httpd" + ((char) 10));                dos2.writeBytes("exit 0" + ((char) 10));                dos2.flush();                dos2.close();                p2.waitFor();                test = pOut2.readLine();                int count = 0;                while (test != null) {                    count++;                    test = pOut2.readLine();                }                pOut2.close();                threadCount = count;                logger.log(name,                    "Currently " + count + " httpd threads are running.");                /**                 * If the count is 0 is means there are no daemon processes                 * running. This sets the needRestart flag to true which will                 * be picked up in the next iteration.                 */                if (count == 0) {                    needRestart = true;                }                if (shouldRefresh) {                    Process pGraceful = Runtime.getRuntime().                                          exec(apachectlLocation +" graceful");                    pGraceful.waitFor();                    shouldRefresh = false;                }            } catch (Exception e) {                logger.err(name, "error checking for processes - ignored");                e.printStackTrace();            }        }        try {            synchronized (this) {                // kill only if we still want to kill apache                // someone may have restarted it with a new thread                if (!getApacheState()) {                    logger.log(name, "stopping apache");                    p = Runtime.getRuntime().exec(apachectlLocation + " stop");                    logger.log(name, "apache stopped");                }            }        } catch (Exception e) {            e.printStackTrace();        }    }