dcsimg

How do i implement synchronized blocks in my C/C++ JNI code?

Davanum Srinivas

The equivalent for

synchronized (obj) {
    ...                   /* synchronized block */
}

is as follows:

(*env)->MonitorEnter(obj);
...                      /* synchronized block */
(*env)->MonitorExit(obj);