On Tue, 31 May 2022 17:41:08 GMT, Mandy Chung <mch...@openjdk.org> wrote:
> Hmm... one benefit of Cleaner is the ease of use to avoid the need of > managing the reference queue. If the performance of the Cleaner API is a > concern, perhaps we should look into reducing its overhead? The code using a Cleaner here creates a CountDownLatch to wait on; that along with the Cleaner seems very similar to the complexity of the suggested alternative directly using a ReferenceQueue. But I'm fine with it either way Each Cleaner creates a new OS thread, used for a single instance of ForceGC. The caching of the Cleaner in a Static mostly reduces the per ForceGC overhead. When Loom is a feature, a Virtual Thread would be sufficient. ------------- PR: https://git.openjdk.java.net/jdk/pull/8907