Comprehensive parsing of GC and ghost references in Java

There are four types of references in Java: strongreference, softreference, WeakReference and phantom reference. These four types of references are closely related to GC. Let's look at their definitions and usage scenarios one by one:

1. Strongreference strongreference is the default reference implementation of Java. It will survive in the JVM as long as possible. When no object points to it, it will be recycled after GC execution

Java code

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>