gpt4 book ai didi

java - 什么是弱全局引用?它与全局引用有何不同?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:26:36 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com