title: Groovy OnStart timer task - how to block for task to finish before next task
body: <p>My application invokes the following timer task from another class OnStart right away, one of the problems I'm trying to avoid is having the the next task invoked before the first one is done. How do I approach this?</p>
  
  <pre><code>import ratpack.server.Service
  import ratpack.server.StartEvent
  import ratpack.server.StopEvent
  import java.util.timer.*
  
  class FTPPoller implements Service {
  
      @Override
      void onStart(StartEvent event) throws Exception {
          println 'Hey, I started'
          new Timer().schedule({FTPlisten.FTPdownload("localhost", "*****", "*****")} as TimerTask, 1000, 5000)
      }
  }
  </code></pre>