Assume I have a daemon-style Java program (one that repeatedly executes a code block forever until terminated). I have code in it to periodically check for the presence of a file, and if present, delete the file and gracefully shut the program down.
To shut down the program, rather than kill
ing its process, I would simply touch
the file and wait for the program to shut down (and for the file to disappear).
- Is this a good practice or bad practice? What are the reasons?
- What other ways can the graceful shut down of a Java program be implemented?
Note: I already saw this question, however none of the answers satisfy the questions above.