synchronized
native
如果可能,最好将对 native 方法的调用排除在同步上下文之外,因为这样的调用会导致成本高昂的上下文切换,并且可能导致性能问题。
示例:
native void nativeMethod(); void example(){ synchronized (lock){ nativeMethod();//警告 } }