Permalink
Browse files

do not clear interrupted flag in Unsafe.park

Since park does not throw InterruptedException, we must leave the flag
set if we are interrupted while parked so that
e.g. AbstractQueuedSynchronizer can itself throw an exception if
appropriate.
  • Loading branch information...
1 parent 4e12847 commit ed9669316632d648248f57b9dafd49e0c3b592a1 @dicej dicej committed May 1, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/builtin.cpp
View
@@ -691,10 +691,12 @@ Avian_sun_misc_Unsafe_park
}
monitorAcquire(t, interruptLock(t, t->javaThread));
+ bool interrupted = false;
while (time >= 0
and (not (threadUnparked(t, t->javaThread)
- or monitorWait
- (t, interruptLock(t, t->javaThread), time))))
+ or threadInterrupted(t, t->javaThread)
+ or (interrupted = monitorWait
+ (t, interruptLock(t, t->javaThread), time)))))
{
int64_t now = t->m->system->now();
time -= now - then;
@@ -704,6 +706,9 @@ Avian_sun_misc_Unsafe_park
break;
}
}
+ if (interrupted) {
+ threadInterrupted(t, t->javaThread) = true;
+ }
threadUnparked(t, t->javaThread) = false;
monitorRelease(t, interruptLock(t, t->javaThread));
}

0 comments on commit ed96693

Please sign in to comment.