作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们可以在另一个线程中使用在一个线程上初始化的jmethodID
吗?我问这个问题是因为当我运行 jni 程序时,我的 jvm 崩溃了,其中我在一个线程上初始化了 jmethodID 并在另一个线程中使用它。我在想这是否可以成为一个原因。
我通过在顶部声明将 jmethodID
保留为全局变量。然后在其中一个调用中我初始化它,并在后续调用中尝试重用它。
最佳答案
A field or method ID does not prevent the VM from unloading the class from which the ID has been derived. After the class is unloaded, the method or field ID becomes invalid. The native code, therefore, must make sure to:
keep a live reference to the underlying class, or
recompute the method or field IDif it intends to use a method or field ID for an extended period of time.
关于java - 在一个线程上初始化的jmethodID可以在另一个线程中使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10909468/
我是一名优秀的程序员,十分优秀!