MonitorEnter - happens-before?
Hello,
Does JNI's MonitorEnter/MonitorExit guarantee a happens-before
relationship on native side memory like "synchronized" does on Java
side ( http://java.sun.com/docs/books/tutorial/essential/concurrency/syncmet...
)? I.e. obviously it should provide happens-before for any Java
Objects that get manipulated on the native side, but does it provide
happens-before for native objects that get manipulated?
For example:
some C++ object has a member variable named obj and two JNI methods:
jniMethod1 and jniMethod2
Starting state: obj->getValue() would return 0
Java Thread 1 calls jniMethod1 which looks like:
MonitorEnter
obj->setValue(3)
MonitorExit
Java Thread 2 calls jniMethod2 which looks like:
MonitorEnter
print obj->getValue()
MonitorExit
Assuming that Thread 1 calls MonitorEnter first and no other calls are
made to obj->setValue() , can I be certain that 3 will always be
printed (as opposed to 0)?
Thanks!

