 <p>Are you using the Timer in daemon mode? Please see this documentation which says what's a daemon thread.</p> <pre><code>/** * Creates a new timer whose associated thread may be specified to * {@linkplain Thread#setDaemon run as a daemon}. * A daemon thread is called for if the timer will be used to * schedule repeating "maintenance activities", which must be * performed as long as the application is running, but should not * prolong the lifetime of the application. * * @param isDaemon true if the associated thread should run as a daemon. */ public Timer(boolean isDaemon) { this("Timer-" + serialNumber(), isDaemon); } </code></pre> <p>If you are using a daemon thread, application will not wait for this thread to finish so any pending operation in this thread is not guaranteed to finish. However, if it's not a daemon thread, the application will shutdown only after this thread finishes its last operation.</p> <p>Coming to the closing of file handles, why don't you do that in the timer thread itself? If that cannot be done, Shudown hooks are the ideal way to do something at the application shutting down time.</p> <p>So, you can have a common lock, which can be acquired by the timer for every task execution and the same lock can be acquired by the shutdown task to close the open file handles.</p> <p>I hope that makes things clear.</p>