Created
April 11, 2020 10:30
-
-
Save magdamiu/d6cc48aecd70b56fa5f9956ae6701c3c to your computer and use it in GitHub Desktop.
Cancellation using withTimeout / withTimeoutOrNull
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.* | |
fun main() { | |
runBlocking { | |
withTimeout(1000L) { | |
repeat(50) { waitingTime -> | |
println("Job is waiting $waitingTime...") | |
delay(100L) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment