StrongReference 强引用
- 回收时机:从不回收
- 使用:对象的一般保存
- 生命周期:JVM停止的时候才会终止
SoftReference 软引用
- 回收时机:当内存不足的时候
- 使用:SoftReference
结合ReferenceQueue构造 - 生命周期:内存不足时终止
WeakReference 弱引用
- 回收时机:在垃圾回收的时候
- 使用:同软引用
- 生命周期:GC后终止
PhatomReference 虚引用
- 回收时机:在垃圾回收的时候
- 使用:合ReferenceQueue来跟踪对象被垃圾回收期回收的活动
- 生命周期:GC后终止