https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

stepango

03/11/2018, 3:47 PM
@gildor sure
Copy code
fun main(args: Array<String>) {
    launch(EmptyCoroutineContext) {
        withContext(EmptyCoroutineContext) {
            CompletableFuture.runAsync {
                print("Hello")
            }.await()
        }
    }
}

suspend fun <T> CompletableFuture<T>.await() = suspendCoroutine<T> { cont ->
    cont.resume(join())
}
Hello
would never be printed in this case
g

gildor

03/11/2018, 11:41 PM
Haa? Why do you use empty context? I mean it doesn't make any sense on JVM, you need a thread
2 Views