java

Shutdown Hook

까망거북 2010. 6. 4. 16:58


        ShutDown shutDown = new ShutDown(this);
        Runtime.getRuntime().addShutdownHook(shutDown);


public class ShutDown extends Thread {   
 
   private ProcessSchedulerMain tcm = null;
   
    public ShutDown(ProcessSchedulerMain _obj){
        tcm = _obj;
    }

    public void run(){
        ShutDownProcess();
    }
   
    private void ShutDownProcess(){
        logger.info("Client Shutdown");
        System.out.println("Shutdown OK?");
    }

}


자바 프로세스가 종료시 구동된다.
kill 명령어나 이클립스에서 강제종료는 잡아 내지 못한다.