Each of the reference classes has a get method, and the ReferenceQueue class has a poll method.
每个引用类都有一个get方法,而Reference Queue类有一个poll方法。
In addition, the new reference classes all represent a "weaker" form of a reference than the typical strong reference.
此外,这几个新的引用类都表现出比典型的强引用“更弱”的引用形式。
Recall that if you do not do this, object MyObject will never be reclaimed, mitigating any benefit of the reference classes.
前面说过,如果不这样做,对象MyObject永远都不会被回收,引用类的任何优点都会被削弱。
The main feature of the reference classes is the ability to refer to an object that can still be reclaimed by the garbage collector.
引用类的主要功能就是能够引用仍可以被垃圾收集器回收的对象。
Before the reference classes were introduced, only strong references were available. For example, the following line of code shows a strong reference, obj.
在引入引用类之前,我们只能使用强引用(strong reference)。
The Reference classes can be useful if used for the right situations.
如果使用得当,引用类还是很有用的。
The Reference classes can be useful if used for the right situations.
如果使用得当,引用类还是很有用的。
应用推荐