Calling java method from suspend function

#1

Hi,
I have a suspend function that calling a java method that i am doing some work and again calling kotlin suspend(actually suspending) function and do some work again.Kotlin side suspends but java side continues to work.In code like this

Kotlin side

suspend fun function1(){
javafunction1()
}

suspend fun function2(){
return suspendCancellableCoroutine { cont: CancellableContinuation ->
//some work
}
}

Java side

void javafunction1(){
javafunction2()
function2()
javafunction3()
}

void javafunction2(){
//some work
}

void javafunction3(){
//continues to work
}

Is this situation possible with kotlin and coroutines or am i doing something wrong?

Thanks for help

#2

You have removed some important part in your partial example.
To answer to your question: yes, it is possible, probably you have ignored some coroutine machinery rules.
If you are not interested to coroutine’s implementation details (https://github.com/Kotlin/KEEP/blob/master/proposals/coroutines.md#implementation-details) then you can simply rewrite function2 as:

fun function2() = GlobalScope.future { }

Please format your code, it is really appreciated.