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

Javadoc for Thread.join(long, int) should specify that it waits forever when both arguments are zero

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 13
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      No behavioral changes; only clarification in the javadoc.
    • Scope:
      JDK

      Description

      Summary

      The javadoc of the method Thread#join(long, int) needs to be clarified to cover the corner case when both arguments are zeros.

      Problem

      Currently the documentation only says that the method makes the current thread to wait for specified amount of time. It may give a wrong impression that specifying two zeroes as the arguments will not block the execution of the current thread at all. In fact, calling Thread.join(0, 0) will make the current thread to wait forever for this thread to finish.

      Solution

      Add a sentence to the javadoc, covering the case millis = 0 and nanos = 0.

      Specification

        * Waits at most {@code millis} milliseconds plus
        * {@code nanos} nanoseconds for this thread to die.
      + * If both arguments are {@code 0}, it means to wait forever.
        *

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                igerasim Ivan Gerasimov
                Reporter:
                igerasim Ivan Gerasimov
                Reviewed By:
                Martin Buchholz, Roger Riggs
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: