8371502: serviceability/jvmti/vthread/ThreadListStackTracesTest/ThreadListStackTracesTest.java failing

Reviewed-by: lmesnik, amenkov
This commit is contained in:
Serguei Spitsyn 2025-12-12 04:03:33 +00:00
parent ae85d899d0
commit c46bed7292

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,13 @@ abstract class TestTask implements Runnable {
}
}
public void ensureReadyAndWaiting(Thread vt, Thread.State expState, ReentrantLock rlock) {
// wait while the thread is not ready or thread state is unexpected
while (!threadReady || (vt.getState() != expState) || !rlock.hasQueuedThreads()) {
sleep(1);
}
}
public void ensureReady(Thread vt, Thread.State expState) {
// wait while the thread is not ready or thread state is unexpected
while (!threadReady || (vt.getState() != expState)) {
@ -97,7 +104,7 @@ public class ThreadListStackTracesTest {
String name = "ReentrantLockTestTask";
TestTask task = new ReentrantLockTestTask();
Thread vt = Thread.ofVirtual().name(name).start(task);
task.ensureReady(vt, expState);
task.ensureReadyAndWaiting(vt, expState, reentrantLock);
checkStates(vt, expState);
}