I have a Java application running inside Docker containers in Kubernetes. I would like to introduce a graceful shutdown of the application when Kubernetes sends a SIGTERM signal to the container and keep all the threads alive while the shutdown hook is running.
I have used the addShutdownHook method to register a shutdown hook. It's working and the shutdown hook is ran each time a SIGTERM is sent. However, only that shutdown hook is ran and all the other threads are automatically terminated (e.g. DB connection, servlets, ...).
I would like to keep all the threads alive while the shutdown hook is running. Is there any way to do that?