|
1 | 1 | /* |
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. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -45,8 +45,9 @@ static void sleep(long millis) { |
45 | 45 | } |
46 | 46 |
|
47 | 47 | public void ensureReadyAndWaiting(Thread vt, Thread.State expState, ReentrantLock rlock) { |
| 48 | + sleep(50); // reliability: wait for a potential class loading to complete |
48 | 49 | // 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)) { |
50 | 51 | sleep(1); |
51 | 52 | } |
52 | 53 | } |
@@ -125,11 +126,12 @@ private static void checkStates(Thread vt, Thread.State expState) { |
125 | 126 | int jvmtiExpState = (expState == Thread.State.WAITING) ? |
126 | 127 | JVMTI_THREAD_STATE_WAITING : |
127 | 128 | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER; |
| 129 | + Thread.State state = vt.getState(); |
128 | 130 |
|
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); |
131 | 133 |
|
132 | | - if (vt.getState() != expState) { |
| 134 | + if (state != expState) { |
133 | 135 | failed("Java thread state is wrong"); |
134 | 136 | } |
135 | 137 | if ((singleState & jvmtiExpState) == 0) { |
|
0 commit comments