< prev index next >

src/java.base/share/classes/java/lang/Object.java

Print this page
rev 53560 : 8218022: Repeated words typos in java.base
Reviewed-by: alanb, lancea
Contributed-by: Andrey Turbanov <turbanoff@gmail.com>
   1 /*
   2  * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 413      * this object has been restored as described above.
 414      *
 415      * @apiNote
 416      * The recommended approach to waiting is to check the condition being awaited in
 417      * a {@code while} loop around the call to {@code wait}, as shown in the example
 418      * below. Among other things, this approach avoids problems that can be caused
 419      * by spurious wakeups.
 420      *
 421      * <pre>{@code
 422      *     synchronized (obj) {
 423      *         while (<condition does not hold> and <timeout not exceeded>) {
 424      *             long timeoutMillis = ... ; // recompute timeout values
 425      *             int nanos = ... ;
 426      *             obj.wait(timeoutMillis, nanos);
 427      *         }
 428      *         ... // Perform action appropriate to condition or timeout
 429      *     }
 430      * }</pre>
 431      *
 432      * @param  timeoutMillis the maximum time to wait, in milliseconds
 433      * @param  nanos   additional time, in nanoseconds, in the range range 0-999999 inclusive
 434      * @throws IllegalArgumentException if {@code timeoutMillis} is negative,
 435      *         or if the value of {@code nanos} is out of range
 436      * @throws IllegalMonitorStateException if the current thread is not
 437      *         the owner of the object's monitor
 438      * @throws InterruptedException if any thread interrupted the current thread before or
 439      *         while the current thread was waiting. The <em>interrupted status</em> of the
 440      *         current thread is cleared when this exception is thrown.
 441      * @see    #notify()
 442      * @see    #notifyAll()
 443      * @see    #wait()
 444      * @see    #wait(long)
 445      */
 446     public final void wait(long timeoutMillis, int nanos) throws InterruptedException {
 447         if (timeoutMillis < 0) {
 448             throw new IllegalArgumentException("timeoutMillis value is negative");
 449         }
 450 
 451         if (nanos < 0 || nanos > 999999) {
 452             throw new IllegalArgumentException(
 453                                 "nanosecond timeout value out of range");


   1 /*
   2  * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 413      * this object has been restored as described above.
 414      *
 415      * @apiNote
 416      * The recommended approach to waiting is to check the condition being awaited in
 417      * a {@code while} loop around the call to {@code wait}, as shown in the example
 418      * below. Among other things, this approach avoids problems that can be caused
 419      * by spurious wakeups.
 420      *
 421      * <pre>{@code
 422      *     synchronized (obj) {
 423      *         while (<condition does not hold> and <timeout not exceeded>) {
 424      *             long timeoutMillis = ... ; // recompute timeout values
 425      *             int nanos = ... ;
 426      *             obj.wait(timeoutMillis, nanos);
 427      *         }
 428      *         ... // Perform action appropriate to condition or timeout
 429      *     }
 430      * }</pre>
 431      *
 432      * @param  timeoutMillis the maximum time to wait, in milliseconds
 433      * @param  nanos   additional time, in nanoseconds, in the range 0-999999 inclusive
 434      * @throws IllegalArgumentException if {@code timeoutMillis} is negative,
 435      *         or if the value of {@code nanos} is out of range
 436      * @throws IllegalMonitorStateException if the current thread is not
 437      *         the owner of the object's monitor
 438      * @throws InterruptedException if any thread interrupted the current thread before or
 439      *         while the current thread was waiting. The <em>interrupted status</em> of the
 440      *         current thread is cleared when this exception is thrown.
 441      * @see    #notify()
 442      * @see    #notifyAll()
 443      * @see    #wait()
 444      * @see    #wait(long)
 445      */
 446     public final void wait(long timeoutMillis, int nanos) throws InterruptedException {
 447         if (timeoutMillis < 0) {
 448             throw new IllegalArgumentException("timeoutMillis value is negative");
 449         }
 450 
 451         if (nanos < 0 || nanos > 999999) {
 452             throw new IllegalArgumentException(
 453                                 "nanosecond timeout value out of range");


< prev index next >