문제

Ive got the following ShutdownHook to detect when the application is exited:

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        public void run() {

            // Do what you want when the application is stopping
            sendMsg("", "goOfflineExit", "12");
        }
    }));

This works perfectly on Mac os but for some reason nothing gets fired on Windows.

Any ideas what im missing?

도움이 되었습니까?

해결책

I can think of two possible explanations:

  • The sendMsg(...) call may be happening too late; e.g. after streams have been closed or flushed.

  • The sendMsg(...) call may be throwing an exception. Uncaught exceptions thrown in a shutdown hook typically don't get reported.

If you showed us the code of sendMsg we might be able to figure out a more definite answer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top