title: What is the behavior of running threads started by java.util.Timer when Timer.cancel() is called?
body: <p><a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Timer.html" rel="nofollow">http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Timer.html</a></p>
  
  <p>The reason for this question is that I have a timer running at one-minute intervals which makes a network request that sometimes takes up to 5 seconds to resolve, and then writes to a file on disk. </p>
  
  <p>When the application is terminated, I need to clean up the file handlers, but I don't want to do that if the timer-initiated thread is in currently blocked on a network call, and may attempt to write to a closed file handler later.</p>
  
  <p>It's hard to test deterministically what happens when <code>Timer.stop()</code> is called at an arbitrary point in time, so I'm hoping that someone who either works on Java or has solved a similar problem might be able to help.</p>