[concurrency-interest] Stopping a java.lang.ref.Cleaner's background thread
Roger.Riggs at Oracle.com
Thu Sep 7 09:39:05 EDT 2017
It should not be necessary to do anything to the Cleaner thread.
The thread is set to be a daemon, so it will not inhibit a clean return
Also, the Cleaner thread will stop itself when all of the cleaner
functions have done their cleanup.
On 9/7/2017 4:55 AM, Dávid Karnok wrote:
> 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 quit.
> 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
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest