PhantomReference

在java中,引用的强度有以下四个级别:1.Strong Referece 2. soft reference 3. weak reference 4 PhantomReference

关于PhantomReference有以下几点需要注意:
1 the PhantomReference.get() method always returns null
2 another difference is that the PhantomReference is enqueueed only after the finalize() method has been called.
3 If you want the reference to be added to the reference queue, you have to keep a strong reference to the Phantom reference.(这一点很重要,为了保持phantom reference被回收后,添加到reference queue中,必须有一个strong reference 引用到这些phantom reference)

当phantom reference 被enqueue到队列时,phantom reference引用的referent已经在内存中删除。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值