【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:

New T-shirt Design Contest!

I know you Intel Weebs can draw... ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *