[英]Strong references within weak references
in Java, are strong references accessible from weakly reachable objects are considered as strong references? 在Java中,可从弱可达对象访问的强引用是否被视为强引用?
Example : 示例:
If there is no other pointer on X and Y, I would expect them to get garbage-collected. 如果X和Y上没有其他指针,我会期望它们被垃圾收集。 Am I wrong? 我错了吗?
Even though the term strong reference is used, perhaps it is better to think in terms of reach-ability . 即使使用强引用这一术语,也许最好从达到能力的角度进行思考。
That is, if the object is strongly reachable from a root object it is not eligibility for reclamation -- otherwise, it is. 也就是说,如果从根对象可以很容易地访问该对象,则它不具备回收的资格 - 否则就是。 A strong reference to an object only referenced through a weak reference is not strongly reachable . 强引用到只有通过弱引用引用的对象不是强可到达 。 However, the strong reference is still a strong reference. 但是,强烈的参考仍然是一个强有力的参考。
Happy coding. 快乐的编码。
Both objects may be garbage-collected; 两个对象都可能被垃圾收集; a strong reference from a weakly-referenced object counts as a weak reference. 来自弱引用对象的强引用被视为弱引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.