Created
June 21, 2020 21:48
-
-
Save gabrielkirsten/74e9b5bc8a7064d2987b7ba1309a38d4 to your computer and use it in GitHub Desktop.
Example Kotlin Thread
This file contains hidden or 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 kotlin.system.* | |
fun main() { | |
val executionTime = measureTimeMillis { | |
val task1 = addTen(1) | |
val task2 = addTen(2) | |
println("async task 1: ${task1}") | |
println("async task 2: ${task2}") | |
} | |
println("execution time: [$executionTime] ms") | |
} | |
fun addTen(n: Int): Int { | |
Thread.sleep(1000L) | |
return n + 10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment