I am rather new to Java and I need to construct a way inside of my application to handle a SIGTERM signal so that my application can gracefully shutdown. This means it finishes what it is currently working on and does not accept new work. The application will shutdown after the in-progress work is completed successfully.
If I am correct, I need to use addShutdownHook but I am unclear as to where this will be implemented.
Do I keep inside the main Java class or do I create a separate Java class? If the latter, how do I call that method in the main Java class?
Does anyone have an example of implementing an addShutdownHook and where they both put it and called it?
Sorry for the rudimentary question but this is all new to me.