title: Asynchronous scheduled job in Kotlin
body: <p>I am trying to understand which is the best way to have an asynchronous job fired at a scheduled rate in Kotlin, while the application is normally running it's normal tasks. Let's say I have a simple application that only prints out "..." every second, but every 5 seconds I want another job / thread / coroutine (which ever suits best) to print "you have a message!". For the async job I have a class <code>NotificationProducer</code> and it looks like this.</p>
  
  <pre><code>class NotificationProducer {
  
      fun produce() {
          println("You have a message!")
      }
  } 
  </code></pre>
  
  <p>Then, my main method looks like this.</p>
  
  <pre><code>    while (true) {
          println("...")
          sleep(1000)
      }
  </code></pre>
  
  <p>Should I use <code>GlobalScope.async</code>, <code>Timer().schedule(...)</code> or some Quartz job to achieve what I want? Any advice is highly appreciated. The point is that notification must come from another class (e.g. NotificationProducer)</p>