title: Callback/event from Java timer
body: <p>I'm writing a basic file monitor to check for new files in a directory. I haven't got a lot of experience with Java so I don't know what the recommended way of doing this is but here's what I have in mind:</p>
  
  <ol>
  <li>Create a Timer and a TimerTask subclass to check for changes in a directory path</li>
  <li>Dispatch event/notify back from the TimerTask subclass if the directory changed/a new file was added</li>
  </ol>
  
  <p>I haven't done any event dispatching in Java but Googled a bit and found a lot of results revolving around swing/gui components which I'm not interested in at the moment. I was looking at the Observable class as well, but the issue is I need to notify from the TimerTask subclass which I can't do because I can't extend two classes. The project should be simple enough, a basic callback (passing a reference to a function from outside the TimerTask subclass to be called from within the TimerTask when conditions are met) would do. </p>
  
  <p>What do you recommend ? What would be the simplest approach ?</p>