< prev index next >

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

Print this page

        

@@ -345,11 +345,24 @@
      * @see    #notify()
      * @see    #notifyAll()
      * @see    #wait()
      * @see    #wait(long, int)
      */
-    public final native void wait(long timeoutMillis) throws InterruptedException;
+    public final void wait(long timeoutMillis) throws InterruptedException {
+        try {
+            wait0(timeoutMillis);
+        } catch (InterruptedException e) {
+            Fiber<?> fiber = Fiber.currentFiber();
+            if (fiber != null) {
+                fiber.isInterrupted(true);
+            }
+            throw e;
+        }
+    }
+
+    // final modifier so method not in vtable
+    private final native void wait0(long timeoutMillis) throws InterruptedException;
 
     /**
      * Causes the current thread to wait until it is awakened, typically
      * by being <em>notified</em> or <em>interrupted</em>, or until a
      * certain amount of real time has elapsed.
< prev index next >