Created
September 9, 2021 10:21
-
-
Save kabutz/6cc4cb5a6518d3a09ffb76b61701005a 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
// run with java -showversion CleanerDemo in Java 16 and 17 to see different results | |
import java.lang.ref.*; | |
public class CleanerDemo { | |
public static void main(String... args) throws InterruptedException { | |
Cleaner cleaner = Cleaner.create(); | |
Cleaner.Cleanable cleanable = cleaner.register(new Object(), | |
() -> System.out.println("My cleaner thread priority is " + | |
Thread.currentThread().getPriority())); | |
System.gc(); | |
Thread.sleep(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment