Skip to content

Instantly share code, notes, and snippets.

View dacape-dev's full-sized avatar
😃

Daniel Carvajal Pelicano dacape-dev

😃
View GitHub Profile
import kotlinx.coroutines.*
fun main(args: Array<String>) {
println("start")
runBlocking {
launch {
println("main runBlocking: Current thread name: ${Thread.currentThread().name}")
}
import kotlinx.coroutines.*
fun main(args: Array<String>) {
println("start")
val deferredResult: Deferred<String> = GlobalScope.async {
delay(1000L)
"Dacape.dev"
}
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
fun main(args: Array<String>) {
println("start")
GlobalScope.launch {
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
fun main(args: Array<String>) {
println("start")
runBlocking {
println("before delay.")
delay(1000)
println("after delay.")
import kotlinx.coroutines.*
fun main(args: Array<String>) = runBlocking {
val coroutine1=async { delay1() }
val coroutine2=async { delay2() }
println(coroutine1.await()+coroutine2.await())
}
suspend fun delay1(): String {
delay(3000)
import kotlinx.coroutines.*
fun main(args: Array<String>) = runBlocking {
var text1 = delay1()
println(text1)
var text2 = delay2()
println(text2)
}
suspend fun delay1(): String {