package com.example.coroutine
import kotlinx.coroutines.*
class UserDataManager {
suspend fun getTotalUserCount(): Int {
var count = 0
CoroutineScope(Dispatchers.IO).launch {
delay(1000)
count = 50
}
val deferred = CoroutineScope(Dispatchers.IO).async {
//its will delay 3 sec
delay(3000)
return@async 70
}
return count + deferred.await()
}
}
No comments:
Post a Comment