Skip to content

Instantly share code, notes, and snippets.

@msgile
Last active June 17, 2017 19:05
Show Gist options
  • Save msgile/94c6e2a1fcad9a9a6ec12bcb1089cc4a to your computer and use it in GitHub Desktop.
Save msgile/94c6e2a1fcad9a9a6ec12bcb1089cc4a to your computer and use it in GitHub Desktop.
Kotlin code showing simple computer before coroutines
package test.coroutines
fun computeA(): Int {
Thread.sleep(2_000) //simulate work
return 10
}
fun computeB(): Int {
Thread.sleep(2_000) //simulate work
return 5
}
fun computer(): Int {
val partA = computeA()
val partB = computeB()
return partA + partB
}
val total = computer() // = 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment