Skip to content

Commit d19d40b

Browse files
author
duke
committed
Backport 12894a8
1 parent a45364a commit d19d40b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/hotspot/jtreg/serviceability/jvmti/vthread/ThreadListStackTracesTest/ThreadListStackTracesTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2023, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -45,8 +45,9 @@ static void sleep(long millis) {
4545
}
4646

4747
public void ensureReadyAndWaiting(Thread vt, Thread.State expState, ReentrantLock rlock) {
48+
sleep(50); // reliability: wait for a potential class loading to complete
4849
// wait while the thread is not ready or thread state is unexpected
49-
while (!threadReady || (vt.getState() != expState) || !rlock.hasQueuedThreads()) {
50+
while (!threadReady || (vt.getState() != expState) || !rlock.hasQueuedThread(vt)) {
5051
sleep(1);
5152
}
5253
}
@@ -125,11 +126,12 @@ private static void checkStates(Thread vt, Thread.State expState) {
125126
int jvmtiExpState = (expState == Thread.State.WAITING) ?
126127
JVMTI_THREAD_STATE_WAITING :
127128
JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER;
129+
Thread.State state = vt.getState();
128130

129-
System.out.printf("State: expected: %s single: %x multi: %x\n",
130-
vt.getState(), singleState, multiState);
131+
System.out.printf("State: expected: %s, vt.getState(): %s, jvmtiExpState: %x single: %x multi: %x\n",
132+
expState, state, jvmtiExpState, singleState, multiState);
131133

132-
if (vt.getState() != expState) {
134+
if (state != expState) {
133135
failed("Java thread state is wrong");
134136
}
135137
if ((singleState & jvmtiExpState) == 0) {

0 commit comments

Comments
 (0)