A thread chosen to be a successor should not be suspended.
The waiting thread is made to be a successor and is unparked. Upon a suspension request, the thread will suspend itself whilst clearing the successor. The OM will be left unlocked (not grabbed by any thread), while the other threads are parked until a thread grabs the OM and then exits it. The suspended thread is on the entry-list and can be selected as a successor again. None of other threads can be woken up to grab the OM until the suspended thread has been resumed and successfully releases the OM.
Suspension of the successor thread can happen in three places in the re-entry part of ObjectMonitor::wait():
1) When the object ThreadBlockInVMPreprocess<ClearSuccOnSuspend> tbivs(current, csos, true /* allow_suspend */) is destroyed right after the thread is unparked in wait().
2) When the object ThreadBlockInVMPreprocess<ClearSuccOnSuspend> tbivs(current, csos, true /* allow_suspend */) is destroyed in reenter_internal().
3) When JvmtiExport::post_monitor_waited(current, this, ret == OS_TIMEOUT) is called.
The waiting thread is made to be a successor and is unparked. Upon a suspension request, the thread will suspend itself whilst clearing the successor. The OM will be left unlocked (not grabbed by any thread), while the other threads are parked until a thread grabs the OM and then exits it. The suspended thread is on the entry-list and can be selected as a successor again. None of other threads can be woken up to grab the OM until the suspended thread has been resumed and successfully releases the OM.
Suspension of the successor thread can happen in three places in the re-entry part of ObjectMonitor::wait():
1) When the object ThreadBlockInVMPreprocess<ClearSuccOnSuspend> tbivs(current, csos, true /* allow_suspend */) is destroyed right after the thread is unparked in wait().
2) When the object ThreadBlockInVMPreprocess<ClearSuccOnSuspend> tbivs(current, csos, true /* allow_suspend */) is destroyed in reenter_internal().
3) When JvmtiExport::post_monitor_waited(current, this, ret == OS_TIMEOUT) is called.
- relates to
-
JDK-8371596 Nits and typos found during review of fix for JDK-8366659
-
- Open
-
- links to
-
Review(master)
openjdk/jdk/27040