【ANDROID STUDIO】Unstructured Concurrency

 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:

My New Favorite Music Genre Is Polish Noir

These 10 artists create music that is mystical, melancholy, magical, and more. ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏    ...

Contact Form

Name

Email *

Message *