Last active
June 17, 2017 19:05
-
-
Save msgile/94c6e2a1fcad9a9a6ec12bcb1089cc4a to your computer and use it in GitHub Desktop.
Kotlin code showing simple computer before coroutines
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
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