diff --git a/src/builtin.cpp b/src/builtin.cpp index 956d52e7e4..ba67ef82f7 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -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)); }