Last active
April 28, 2021 07:55
-
-
Save soudmaijer/f29a1b49f64ede858d46e9ad3737bfdf to your computer and use it in GitHub Desktop.
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.delay | |
import kotlinx.coroutines.runBlocking | |
import kotlin.system.measureTimeMillis | |
suspend fun loadImage(name: String) { | |
println("Loading image: $name...") | |
delay(2000) // simulate slow behaviour | |
println("Done loading image: $name.") | |
} | |
fun main() { | |
runBlocking { | |
val time = measureTimeMillis { | |
loadImage("image1") | |
loadImage("image2") | |
} | |
println("Loading images took: $time ms.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment