ThreadPoolExecutor and finalization
martinrb at google.com
Mon Oct 30 17:21:45 UTC 2017
On Mon, Oct 30, 2017 at 8:27 AM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> There is a test <repo>/test/jdk/java/util/conc
> It only tests it for Executors of newSingleThreadExecutor, not for the
> so I wondered if there was some open issue.
I wrote that test long ago. But I've always been confused about automatic
thread pool shutdown; it's not very reliable, especially given that all the
threads need to terminate. Should TPE's finalization spec apply to STPE?
TPE is a brittle class; we avoid doing too much surgery on it (even though
we're in the middle of doing exactly that to fix an actual bug).
> The initiative is to identify and remediate existing uses of finalization
in the JDK.
I've been skeptical about this initiative as stated. I would not have
deprecated finalize(). We will never remove finalize() from the JDK, and I
don't see how switching TPE from finalize to some other mechanism such as
Cleaner has real benefits for users. There aren't enough instances of TPE
created for finalization to be a real user performance problem.
TPE's spec currently has a finalize deprecation warning, but this is not
helpful for users.
(a documentation readability regression!)
More information about the core-libs-dev