void sample_function(JNIEnv *env, jobject obj) {
...
{ // start the critical section block
JNIMonitor mon(env, obj);
// do the critical section stuff here
...
// the destructor of 'mon' automatically exits
// the underlying Java monitor
}
...
}
End of Listing