RFR: 8288984: Simplification in java.lang.Runtime::exit [v2]

Kim Barrett kbarrett at openjdk.org
Tue Jul 5 21:59:40 UTC 2022


On Mon, 4 Jul 2022 12:19:27 GMT, David Holmes <dholmes at openjdk.org> wrote:

> > Let's say we've run shutdown so run all the hooks but not halted. Then someone calls exit(0). That seems to suggest the call will block indefinitely, which is neither desirable nor what was actually implemented.
> 
> If the hook threads do not halt then the exiting thread (which holds the lock) blocks forever in the join(). Any other call to exit blocks trying to acquire the lock. That has always been the way this works - if hook threads don't terminate then the VM doesn't (unless someone calls halt() directly). That is one of the things the window you suggested be closed, allowed - a call to exit(non-zero) could force a call to halt().

I think that isn't true.  If a hook doesn't terminate then VM.shutdown doesn't get called, so the window never gets cracked opened to call halt directly.

-------------

PR: https://git.openjdk.org/jdk/pull/9351


More information about the core-libs-dev mailing list