< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/newclass02/java.base/java/lang/Object.java

Print this page

351      * <p>
352      * This method should only be called by a thread that is the owner
353      * of this object's monitor. See the <code>notify</code> method for a
354      * description of the ways in which a thread can become the owner of
355      * a monitor.
356      *
357      * @param      timeout   the maximum time to wait in milliseconds.
358      * @exception  IllegalArgumentException      if the value of timeout is
359      *               negative.
360      * @exception  IllegalMonitorStateException  if the current thread is not
361      *               the owner of the object's monitor.
362      * @exception  InterruptedException if another thread interrupted the
363      *             current thread before or while the current thread
364      *             was waiting for a notification.  The <i>interrupted
365      *             status</i> of the current thread is cleared when
366      *             this exception is thrown.
367      * @see        java.lang.Object#notify()
368      * @see        java.lang.Object#notifyAll()
369      */
370     public final void wait(long timeoutMillis) throws InterruptedException {
371         long comp = Blocker.begin();






372         try {
373             wait0(timeoutMillis);
374         } catch (InterruptedException e) {
375             Thread thread = Thread.currentThread();
376             if (thread.isVirtual())
377                 thread.getAndClearInterrupt();
378             throw e;
379         } finally {
380             Blocker.end(comp);
381         }
382     }
383 
384     /**
385      * Causes current thread to wait until another thread invokes the
386      * {@link java.lang.Object#notify()} method or the
387      * {@link java.lang.Object#notifyAll()} method for this object, or
388      * some other thread interrupts the current thread, or a certain
389      * amount of real time has elapsed.
390      * <p>
391      * This method is similar to the <code>wait</code> method of one
392      * argument, but it allows finer control over the amount of time to
393      * wait for a notification before giving up. The amount of real time,
394      * measured in nanoseconds, is given by:
395      * <blockquote>
396      * <pre>
397      * 1000000*timeout+nanos</pre></blockquote>
398      * <p>
399      * In all other respects, this method does the same thing as the
400      * method {@link #wait(long)} of one argument. In particular,

351      * <p>
352      * This method should only be called by a thread that is the owner
353      * of this object's monitor. See the <code>notify</code> method for a
354      * description of the ways in which a thread can become the owner of
355      * a monitor.
356      *
357      * @param      timeout   the maximum time to wait in milliseconds.
358      * @exception  IllegalArgumentException      if the value of timeout is
359      *               negative.
360      * @exception  IllegalMonitorStateException  if the current thread is not
361      *               the owner of the object's monitor.
362      * @exception  InterruptedException if another thread interrupted the
363      *             current thread before or while the current thread
364      *             was waiting for a notification.  The <i>interrupted
365      *             status</i> of the current thread is cleared when
366      *             this exception is thrown.
367      * @see        java.lang.Object#notify()
368      * @see        java.lang.Object#notifyAll()
369      */
370     public final void wait(long timeoutMillis) throws InterruptedException {
371         if (!Thread.currentThread().isVirtual()) {
372             wait0(timeoutMillis);
373             return;
374         }
375 
376         // virtual thread waiting
377         boolean attempted = Blocker.begin();
378         try {
379             wait0(timeoutMillis);
380         } catch (InterruptedException e) {
381             // virtual thread's interrupt status needs to be cleared
382             Thread.currentThread().getAndClearInterrupt();

383             throw e;
384         } finally {
385             Blocker.end(attempted);
386         }
387     }
388 
389     /**
390      * Causes current thread to wait until another thread invokes the
391      * {@link java.lang.Object#notify()} method or the
392      * {@link java.lang.Object#notifyAll()} method for this object, or
393      * some other thread interrupts the current thread, or a certain
394      * amount of real time has elapsed.
395      * <p>
396      * This method is similar to the <code>wait</code> method of one
397      * argument, but it allows finer control over the amount of time to
398      * wait for a notification before giving up. The amount of real time,
399      * measured in nanoseconds, is given by:
400      * <blockquote>
401      * <pre>
402      * 1000000*timeout+nanos</pre></blockquote>
403      * <p>
404      * In all other respects, this method does the same thing as the
405      * method {@link #wait(long)} of one argument. In particular,
< prev index next >