Skip to content

Instantly share code, notes, and snippets.

@gabrielkirsten
Created June 21, 2020 21:48
Show Gist options
  • Save gabrielkirsten/74e9b5bc8a7064d2987b7ba1309a38d4 to your computer and use it in GitHub Desktop.
Save gabrielkirsten/74e9b5bc8a7064d2987b7ba1309a38d4 to your computer and use it in GitHub Desktop.
Example Kotlin Thread
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