7 ms·
I believe reference queues are the way to go about this now. Once you wrap your brain around them, it's far simpler to reason about. The only really issue is t
by mmastrac 5y ago
I believe reference queues are the way to go about this now. Once you wrap your brain around them, it's far simpler to reason about.
The only really issue is that you effectively need to litter your code with queue checks, or dedicate a thread to watching them.
- papercrane 5y agoYou can use the Cleaner API instead. It's pretty straightforward to use. https://download.java.net/java/early_access/jdk18/docs/api/java.base/java/lang/ref/Cleaner.html https://download.java.net/java/early_access/jdk18/docs/api/j...
- mmastrac 5y agoThanks for the pointers - my Java knowledge is apparently out-of-date!