Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kotlinx.coroutines.delay
- import kotlinx.coroutines.launch
- import kotlinx.coroutines.runBlocking
- import kotlinx.coroutines.test.TestCoroutineContext
- import java.util.concurrent.TimeUnit
- fun main() {
- val testCoroutineContext = TestCoroutineContext()
- runBlocking(testCoroutineContext) {
- // runRealWorldTime()
- launch { printIntegersWithDelay(10) }
- testCoroutineContext.advanceTimeBy(9, TimeUnit.MINUTES)
- println()
- delay(1000)
- testCoroutineContext.advanceTimeBy(9, TimeUnit.MINUTES)
- }
- }
- suspend fun printIntegersWithDelay(count: Int) {
- repeat(count)
- {
- delay(100000)
- println ("${Thread.currentThread().id} $it")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement