On Sat, 2 Jul 2022 21:21:37 GMT, Ryan Ernst <d...@openjdk.org> wrote:

>> This is a followup to simplify Shutdown.exit after the removal of
>> finalizers (https://bugs.openjdk.org/browse/JDK-8198250). Once agreement
>> on the approach has been reached in this PR, a CSR will be filed to
>> propose the spec change to Runtime.exit.
>
> Ryan Ernst has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   better clarify multiple threads behavior

> 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().

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

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

Reply via email to