ReferenceUtil

Introduction

Reference tool class, mainly aimed at tooling encapsulation of Reference

Main encapsulations include:

  1. SoftReference: Soft reference, which will be recycled by GC when GC reports insufficient memory.
  2. WeakReference: Weak reference, which will cause the object to be recycled when GC discovers it.
  3. PhantomReference: Phantom reference, which inserts PhantomReference into ReferenceQueue when GC discovers the phantom reference object. At this time, the object has not been truly recycled and will only be recycled after the ReferenceQueue is truly processed.

Methods

create

Create a reference according to the type enumeration.