Hey guys, I've been writing this code to conduct async callbacks from rust to java.
Link to the code: GitHub - Yoga07/java-jni-rust at jni-error
The two threads at the last function of lib.rs
are the ones implementing jni java callbacks and rust functions.
I get different outputs every time I run them. Sometimes it works as it was intended to be. Other times, it doesn't. I am not able to understand this behavior. Eg.
OUTPUT 1:
[Rust]Hello World!
[Java] 8
[Java]hello
[Java]->Name=Lionel, Balance=100.0
[Rust]Rust is processing
Rust->Calls back to Java
[Java]Java executes callbacks
OUTPUT 2:
[Rust]Hello World!
[Java] 8
[Java]hello
[Java]->Name=Lionel, Balance=100.0
[Rust]Rust is processing
OUTPUT 3:
[Rust]Hello World!
[Java] 8
[Java]hello
[Java]->Name=Lionel, Balance=100.0
[Rust]Rust is processing
Rust->Calls back to Java
[Java]Java executes callbacks
[Rust]Rust finishes processing
Java Responds
OUTPUT 3 is the correct and expected out. Please help me clarify this behaviour. Thanks in advance!