8198841: Thread.interrupt should set interrupt status while holding blockerLock
Reviewed-by: bpb
--- 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);
- }
- }
- }
}
/**