@@ -118,18 +118,19 @@ monitorWaitImpl(J9VMThread *vmThread, j9object_t object, I_64 millis, I_32 nanos
118118#endif
119119 J9VMTHREAD_SET_BLOCKINGENTEROBJECT (vmThread, vmThread, object);
120120 object = NULL ;
121- /* Set j.l.Thread status to WAITING. */
122- U_32 oldState = J9_ARE_ANY_BITS_SET (thrstate, J9_PUBLIC_FLAGS_THREAD_TIMED)
123- ? VM_VMHelpers::setThreadState (vmThread, J9VMTHREAD_STATE_WAITING_TIMED)
124- : VM_VMHelpers::setThreadState (vmThread, J9VMTHREAD_STATE_WAITING);
125121#if JAVA_SPEC_VERSION >= 24
126122 J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL (javaVM);
127123#endif /* JAVA_SPEC_VERSION >= 24 */
124+ /* Set j.l.Thread status to UNKNOWN since the wait can be notified/interrupted
125+ * but blocked on re-acquiring the monitor.
126+ * In this case, the thread state will have to be determined by looking at
127+ * the vmThread->publicFlags field.
128+ */
129+ U_32 oldState = VM_VMHelpers::setThreadState (vmThread, J9VMTHREAD_STATE_UNKNOWN);
128130 internalReleaseVMAccessSetStatus (vmThread, thrstate);
129131 rc = timeCompensationHelper (vmThread,
130132 interruptable ? HELPER_TYPE_MONITOR_WAIT_INTERRUPTABLE : HELPER_TYPE_MONITOR_WAIT_TIMED, monitor, millis, nanos);
131133 internalAcquireVMAccessClearStatus (vmThread, thrstate);
132- /* Set j.l.Thread status to oldState. */
133134 VM_VMHelpers::setThreadState (vmThread, oldState);
134135 J9VMTHREAD_SET_BLOCKINGENTEROBJECT (vmThread, vmThread, NULL );
135136 omrthread_monitor_unpin (monitor, vmThread->osThread );
@@ -203,12 +204,10 @@ threadSleepImpl(J9VMThread *vmThread, I_64 millis, I_32 nanos)
203204#endif
204205 if (0 == rc) {
205206 TRIGGER_J9HOOK_VM_SLEEP (javaVM->hookInterface , vmThread, millis, nanos);
206- /* Set j.l.Thread status to SLEEPING. */
207207 U_32 oldState = VM_VMHelpers::setThreadState (vmThread, J9VMTHREAD_STATE_SLEEPING);
208208 internalReleaseVMAccessSetStatus (vmThread, J9_PUBLIC_FLAGS_THREAD_SLEEPING);
209209 rc = timeCompensationHelper (vmThread, HELPER_TYPE_THREAD_SLEEP, NULL , millis, nanos);
210210 internalAcquireVMAccessClearStatus (vmThread, J9_PUBLIC_FLAGS_THREAD_SLEEPING);
211- /* Set j.l.Thread status to oldState. */
212211 VM_VMHelpers::setThreadState (vmThread, oldState);
213212 TRIGGER_J9HOOK_VM_SLEPT (javaVM->hookInterface , vmThread, millis, nanos, startTicks);
214213 }
0 commit comments