Notifying java object from C / C ++ code?

I am wondering if it is possible to notify ( notify()) a java object with native code?

For example, let's say we have a thread in java that is waiting for a signal, as shown below.

void _do_something() throws Exception{
   synchronized(__lock_){
      __lock_.wait();
   }
}

Then is it possible to notify an object __lock_from its own code ?! Should I pass the object __lock_to c-code? as and how the C code calls the method notify(). Any help is appreciated. Thanks in advance.

+4
source share
1 answer

This is very convenient for inline code. You need to use JNI though ...

Then is it possible to notify the _lock object from native code ?!

, _lock, , , (, Java- ).

_lock c?

. , , JNI CallVoidMethod() notify(), , / Monitor ( JNI "synchronized (_lock)"

C notify()

, java. , java , , , , MonitorEnter, CallVoidMethod MonitorExit.

, JNI , , . , . , , .

JNI , ( ), ( stderr -, ) java -Xcheck: jni. , 10-, googled, , .

!

+6

All Articles