public class ShutdownHookTest {
    public static void main(String[] args){
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            public void run() {
                System.out.println("shutting down ...");
		for(int i = 10; i>0; i--){
			System.out.println(i);
			try{
				Thread.sleep(500);
			}catch(InterruptedException e){
				System.err.println(e.getMessage());
			}
		}
		System.out.println("shutdown finished!");
            }
        }));
	while (true){
		System.out.print(".");
		System.out.flush();
		try{
			Thread.sleep(1000);
		}catch(InterruptedException e){
			System.err.println(e.getMessage());
		}
	}
    }
}
