JNI 中的弱全局引用是什么?它与全局引用 和本地引用 有何不同?
最佳答案
我认为您的问题的答案可以在这里找到: http://java.sun.com/docs/books/jni/html/refs.html
如其所写:
Local and global references have different lifetimes. Local references are automatically freed, whereas global and weak global references remain valid until they are freed by the programmer.
局部引用和全局引用的区别在于:上下文
局部引用只是一个局部变量。一旦您离开其上下文(例如从定义它的 native 函数返回),底层对象将被销毁。
Like global references, weak global references remain valid across native method calls and across different threads. Unlike global references, weak global references do not keep the underlying object from being garbage collected.
weak global references 和 global references 的区别在于,如果需要(在内存不足的情况下),weak 引用的对象可以被垃圾回收。
关于java - 什么是弱全局引用?它与全局引用有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10499320/