changeset 49108:b9ee7c274ee0

8198841: Thread.interrupt should set interrupt status while holding blockerLock Reviewed-by: bpb
author alanb
date Thu, 01 Mar 2018 18:27:39 +0000
parents 8d30b4960828
children f2804cb922ce c656e49ff2f8
files src/java.base/share/classes/java/lang/Thread.java
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/Thread.java	Thu Mar 01 10:03:31 2018 -0800
+++ b/src/java.base/share/classes/java/lang/Thread.java	Thu Mar 01 18:27:39 2018 +0000
@@ -1007,22 +1007,22 @@
      * @spec JSR-51
      */
     public void interrupt() {
-        Thread me = Thread.currentThread();
-        if (this != me)
+        if (this != Thread.currentThread()) {
             checkAccess();
 
+            // thread may be blocked in an I/O operation
+            synchronized (blockerLock) {
+                Interruptible b = blocker;
+                if (b != null) {
+                    interrupt0();  // set interrupt status
+                    b.interrupt(this);
+                    return;
+                }
+            }
+        }
+
         // set interrupt status
         interrupt0();
-
-        // thread may be blocked in an I/O operation
-        if (this != me && blocker != null) {
-            synchronized (blockerLock) {
-                Interruptible b = blocker;
-                if (b != null) {
-                    b.interrupt(this);
-                }
-            }
-        }
     }
 
     /**