Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314305

Add -XX:UserThreadWaitAttemptsAtExit=<number_of_waits>

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • hotspot
    • None
    • behavioral
    • minimal
    • There is minimal compatibility risk as this adds a new runtime -XX flag.
    • add/remove/modify command line option
    • JDK

      Summary

      Add -XX:UserThreadWaitAttemptsAtExit=<number_of_waits> flag to override the default max timeout (300 ms) to wait for user threads to stop executing native code during JVM exit.

      Problem

      During JVM shutdown, if there are any user threads executing in native code, the JVM waits for those threads to return to the JVM. The maximum wait time is currently hardcoded to 300 milliseconds. The delay is not always necessary and the JVM can safely shutdown without waiting for the user threads in some environments.

      Solution

      Introduce a -XX:UserThreadWaitAttemptsAtExit=<number_of_waits> flag. The flag is to specify the number of times to wait for user threads to stop executing native code during JVM exit. Each wait lasts 10 milliseconds. The maximum number of waits is 1000, to wait at most 10 seconds.

      Specification

      --- a/src/hotspot/share/runtime/globals.hpp
      +++ b/src/hotspot/share/runtime/globals.hpp
      @@ -836,10 +836,10 @@ const int ObjectAlignmentInBytes = 8;
                 "first occurrence of an out-of-memory error thrown from JVM")     \
                                                                                   \
         product(intx, UserThreadWaitAttemptsAtExit, 30,                           \                                             \
      +          "The number of times to wait for user threads to stop executing " \
      +          "native code during JVM exit. Each wait lasts 10 milliseconds. "  \
      +          "The maximum number of waits is 1000, to wait at most 10 "        \
      +          "seconds.")                                                       \
                 range(0, 1000)                                                    \

      By default, UserThreadWaitAttemptsAtExit is 30, and the JVM may wait up to 300 milliseconds for user threads to stop executing native code when the JVM is exiting. That is the same as the existing behavior.

            jiangli Jiangli Zhou
            jiangli Jiangli Zhou
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: