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

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 13
    • core-libs
    • None
    • minimal
    • No behavioral changes; only clarification in the javadoc.
    • 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

              igerasim Ivan Gerasimov
              igerasim Ivan Gerasimov
              Martin Buchholz, Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: