When the JVM is exiting, VM_Exit::wait_for_threads_in_native_to_block() waits for maximum 300ms if there are any user threads running in native (potentially doing clean-ups). Developer had noticed shutdown delay due to the wait in certain cases and reported the issue on JDK 11.
As user threads must go through native to Java/VM transitions to access VM data, and they will be stopped during the transition if the VM is shutting down. I think the wait with timeout for user thread in VM_Exit::wait_for_threads_in_native_to_block is not really necessary. Particularly in container environments, VM shutdown could be proceeded 'safely' without waiting for user threads in this case. It would be a good idea to make the wait time configurable.
As user threads must go through native to Java/VM transitions to access VM data, and they will be stopped during the transition if the VM is shutting down. I think the wait with timeout for user thread in VM_Exit::wait_for_threads_in_native_to_block is not really necessary. Particularly in container environments, VM shutdown could be proceeded 'safely' without waiting for user threads in this case. It would be a good idea to make the wait time configurable.
- csr for
-
JDK-8314305 Add -XX:UserThreadWaitAttemptsAtExit=<number_of_waits>
- Closed