Created
November 9, 2018 07:26
-
-
Save orionll/162bc4ead5ce2c6ecbaae9b7298ba509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Main { | |
public static void main(String... args) throws Throwable { | |
Integer i = new Integer(1); | |
WeakReference<Integer> ref = new WeakReference<>(i); | |
System.gc(); | |
System.out.println(ref.get()); | |
myStupidReachabilityFence(i); | |
} | |
private static void myStupidReachabilityFence(Integer i) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import java.lang.ref.WeakReference;