coroutines kotlin android dependency
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
}
coroutines kotlin android dependency
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
}
kotlin coroutines
import kotlinx.coroutines.*
// Asynchronous execution
fun main() {
GlobalScope.launch { // creates a new coroutine and continues
doWorld() // suspending function
}
println("World !") // execution continues even while coroutine waits
runBlocking { // block main thread for 4 s (waits for 1rst coroutine)
delay(4000L)
}
}
suspend fun doWorld() {
delay(2000L) // non-blocking delay for 2000 milliseconds
println("Hello") // printed after "World !"
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us