On Sun, 3 Jul 2022 22:19:50 GMT, David Holmes <dhol...@openjdk.org> wrote:

>> Ryan Ernst has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   better clarify multiple threads behavior
>
> src/java.base/share/classes/java/lang/Runtime.java line 89:
> 
>> 87:      * of the first invocation will be used; the status codes from other 
>> invocations
>> 88:      * will be ignored. If this method is invoked from a shutdown hook 
>> the system
>> 89:      * will deadlock.
> 
> Expressing this accurately is tricky - what is "first" here? I suggest the 
> following:
> 
>> Invocations of this method are serialized such that only one invocation will 
>> actually proceed with the shutdown sequence and terminate the VM with the 
>> given status code. All other invocations will block indefinitely. If this 
>> method is invoked from a shutdown hook the system will deadlock.

+1 - except for the "deadlock" part (see other comment).  I think the old 
paragraph is at least confusing, and perhaps even just wrong.  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.

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

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

Reply via email to