File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
test/jdk/java/lang/Thread/virtual Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 4141 */
4242
4343import java .util .concurrent .atomic .AtomicBoolean ;
44+ import java .util .concurrent .CountDownLatch ;
4445
4546import jdk .test .lib .thread .VThreadPinner ;
4647import org .junit .jupiter .api .Test ;
4748import static org .junit .jupiter .api .Assertions .*;
4849
4950class ThreadPollOnYield {
51+ private static final CountDownLatch started = new CountDownLatch (1 );
5052 static void foo (AtomicBoolean done ) {
53+ started .countDown ();
5154 while (!done .get ()) {
5255 Thread .yield ();
5356 }
@@ -59,7 +62,7 @@ void testThreadYieldPolls() throws Exception {
5962 var vthread = Thread .ofVirtual ().start (() -> {
6063 VThreadPinner .runPinned (() -> foo (done ));
6164 });
62- Thread . sleep ( 5000 );
65+ started . await ( );
6366 done .set (true );
6467 vthread .join ();
6568
You can’t perform that action at this time.
0 commit comments