[concurrency-interest] Stopping a java.lang.ref.Cleaner's background thread

Dávid Karnok akarnokd at gmail.com
Thu Sep 7 04:55:51 EDT 2017


Java 9 introduced the handy and official Cleaner infrastructure to replace
the functionality of finally(). It allows us to create the thread it is
going to use for the cleanup, which is set to daemon so that the JVM can

However, when running in an "app" container such as Tomcat, I'm not sure
how to cleanup the Cleaner itself when the servlet gets unloaded. (We had
similar issues with RxJava's own set of standard schedulers which made us
expose the shutdown of the underlying thread pools so a servlet can stop
them when it gets unloaded.)

I'm not sure what the effect of such shutdown should be beyond stopping the
underlying threadpool. Calling clean() on all registered Cleanables and
rejecting further register() calls? Returning all registered Cleanables?

Best regards,
David Karnok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20170907/4a7a4de4/attachment.html>

More information about the Concurrency-interest mailing list