Hacker News new | ask | show | jobs
by jillesvangurp 1414 days ago
A lot of multi threaded server software handles ctr+c just fine. A lot of Java based server software have a shutdown hook, which is something that you can easily add to any jvm based program because it is part of the standard library. If you use Spring Boot, for example, it has one and it will start shutting down your Spring Context and call any destroy functions on DestroyingBean implementations, which is how you can add your own shut down logic in Spring.

Good explanation here of shutdown hooks: https://www.baeldung.com/jvm-shutdown-hooks