Closed hrj closed 8 years ago
Alternatively, I guess I could create a wrapper java.lang.Thread
instance in Java code, whose run
method invokes the method
, pass the java.lang.Thread
instance to native code, and then call thread.start()
from native code.
This should avoid using non-standard APIs, but at the cost of a round-trip to Java land.
It looks like there is no official API to launch a new thread from native code. (That makes sense in a way; probably closer to the JVM standard).
So I am instead creating a thread from JVM land in advance, and then sending a wake-up message to it from native. (We have been doing this for other scenarios too, so it's not a big deal).
Sorry for the delay; I was traveling for awhile.
You're correct; you should not launch a new thread from native code. Instead, you should spawn threads from within Java.
In a native function, I have a Java object and a
java.lang.reflect.Method
instance. I want to launch this method in a new JVM thread. What's the best way to do this?In pseudo-code:
Thanks!