Hypothetical scenario:
I have a daemon thread responsible for some I/O, the main thread finishes and returns, and the JVM decides to terminate my daemon thread.
How does it do so? Interrupt? Finalize? How can I code my daemon thread so that it reacts gracefully when terminated?