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

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *