JVM does not shut down after shutting down the swing application

I have a rotation application with an exit button that calls a method that calls System.exit (0); but the JVM is not closing for some reason. Does anyone know what might cause the JVM to continue working?

+4
source share
2 answers

Non-daemon threads will not stop program execution when System.exit() called (and daemon threads will certainly not), but trailing hooks & dagger; will be if they are not completed.

& cross See Shutdown Hooks API Design (the originally linked article is now only available on the return path machine ).

Swing probably uses interrupts, but not so that your program does not interrupt. But if you (or some library that you use) call Runtime.addShutdownHook() , you must make sure that your shutdowns are not blocked.

By the way, one problem for this problem is to add a disconnect hook that looses another thread that waits sixty seconds, then calls Runtime.halt() . (You will have to unscrew another thread, because otherwise the stop hook, waiting for sixty seconds, will not allow the program to shut down for sixty seconds.)

+5
source

Perhaps you have Thread that still works?

It is very easy to find which threads work and when. In Netbeans, run your project in profile mode (Alt + F2) to have a real-time snapshot. (Profiler β†’ Browse β†’ Themes)

+2
source

Source: https://habr.com/ru/post/1335182/


All Articles