Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kotlinx.coroutines.*
- // TODO 1
- suspend fun sum(valueA: Int, valueB: Int): Int {
- delay(3000L)
- return valueA+valueB
- }
- // TODO 2
- suspend fun multiple(valueA: Int, valueB: Int): Int {
- delay(2000L)
- return valueA*valueB
- }
- fun main() = runBlocking {
- println("Counting...")
- val resultSum = async { sum(10, 10) }
- val resultMultiple = async { multiple(20, 20) }
- // TODO 3
- println("Result sum: ${resultSum.await()}")
- println("Result multiple: ${resultMultiple.await()}")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement