title: Having A Timer Use The Main Thread in Kotlin
body: <p>I have an operation that needs to be delayed for a few seconds. I am using the scheduler and timer like so:</p>
  
  <pre><code>import java.util.Timer
  import kotlin.concurrent.timerTask
  
   val timer = Timer()
          sliderLastAdjusted = System.currentTimeMillis()
  
          timer.schedule(timerTask {
              val newTime = System.currentTimeMillis()
              val elapsedTime = newTime - sliderLastAdjusted
  
              if (elapsedTime &gt; 2000) {
  
                  masterViewModel.updateLeagueProjections()
              }
          }, 2000)
  </code></pre>
  
  <p>While this works for executing a command with a delayed time and prevents other commands within the same time period from executing, it does use the main thread - which causes an issue when updating observables.</p>
  
  <p>How can I get this to use the MainThread?</p>