title: Repeat a task within a duration with delay
body: <p>I have to move a progress bar within a time frame, for example within 6s. I am using coroutines and the "repeat" function. The code executes except that the total execution time is not as specified. Below is my code.</p>
  
  <pre><code>val progressJob = Job()
  var startTime = 0L
  CoroutineScope(Dispatchers.Default + progressJob).launch {
      startTime = System.currentTimeMillis()
      repeat(1000) {
          progressBar.progress += 1
          delay(6)
      }
      Log.d(TAG, "total time= ${System.currentTimeMillis() - startTime}")
  }
  </code></pre>
  
  <p>I am expecting "total time" would be 6000, but I am getting values greater than 6000 by at least 500. </p>
  
  <p>Basically I just want to repeatedly increment the progress bar within a time frame, and I am not using animation because of performance issue.</p>
  
  <p>Is there anything I am missing?</p>