@@ -1868,8 +1868,19 @@ startJavaThread(J9VMThread * currentThread, j9object_t threadObject, UDATA priva
18681868 privateFlags &= ~J9_PRIVATE_FLAGS_NO_EXCEPTION_IN_START_JAVA_THREAD;
18691869
18701870#ifndef J9VM_IVE_RAW_BUILD /* J9VM_IVE_RAW_BUILD is not enabled by default */
1871+ #if JAVA_SPEC_VERSION >= 19
1872+ j9object_t threadHolder = J9VMJAVALANGTHREAD_HOLDER (currentThread, threadObject);
1873+ if (NULL != threadHolder) {
1874+ J9VMJAVALANGTHREADFIELDHOLDER_SET_THREADSTATUS (currentThread, threadHolder, J9VMTHREAD_STATE_RUNNING);
1875+ }
1876+ #else /* JAVA_SPEC_VERSION >= 19 */
1877+ J9VMJAVALANGTHREAD_SET_THREADSTATUS (currentThread, threadObject, J9VMTHREAD_STATE_RUNNING);
1878+ #endif /* JAVA_SPEC_VERSION >= 19 */
18711879 /* Any attempt to start a Thread makes it illegal to attempt to start it again.
1872- * Oracle class libraries don't have the 'started' field */
1880+ * Oracle class libraries don't have the 'started' field.
1881+ *
1882+ * Thread.started must be set after Thread.threadStatus to avoid timing issue in Thread.getState().
1883+ */
18731884 J9VMJAVALANGTHREAD_SET_STARTED (currentThread, threadObject, TRUE );
18741885#endif /* !J9VM_IVE_RAW_BUILD */
18751886
@@ -2033,9 +2044,6 @@ startJavaThreadInternal(J9VMThread * currentThread, UDATA privateFlags, UDATA os
20332044 }
20342045 J9VMJAVALANGTHREAD_SET_THREADREF (currentThread, threadObject, newThread);
20352046
2036- /* Set j.l.Thread status to RUNNABLE. */
2037- VM_VMHelpers::setThreadState (currentThread, J9VMTHREAD_STATE_RUNNING);
2038-
20392047#if (JAVA_SPEC_VERSION >= 14)
20402048 /* If thread was interrupted before start, make sure interrupt flag is set for running thread. */
20412049 if (J9VMJAVALANGTHREAD_DEADINTERRUPT (currentThread, threadObject)) {
0 commit comments