Created
October 31, 2019 23:40
-
-
Save pencelab/83b2b2e1d8db825d3b32632e66fb2b27 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
private suspend fun sumThreeRandomNumbers(operation: String): Int { | |
val sum = withContext(Dispatchers.Default) { | |
val r1 = async { myRandomNumberFail(operation) } | |
val r2 = async { myRandomNumberSuccess(operation) } | |
val r3 = async { myRandomNumberSuccess(operation) } | |
r1.await() + r2.await() + r3.await() | |
} | |
return sum | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment