On Fri, 21 Aug 2026 16:23:22 GMT, Fabian Meumertzheim <[email protected]> wrote:

> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

test/jdk/java/util/concurrent/forkjoin/GetMultipleWaiters.java line 110:

> 108:             a.start();
> 109:             while (a.getState() != Thread.State.TIMED_WAITING)
> 110:                 Thread.sleep(1);

I'd create a static method for this, something like:


static void startAndAwaitState(Thread t, Thread.State state) throws Exception {
    t.start();
    while(t.getState() != state)
        Thread.sleep(1);
}


That would reduce the number of places where sleep adjustments would need to 
get made.

You could even go as far as:


static Thread startThreadAndAwaitState(Runnable r, String name, Thread.State 
state) throws Exception {
    var t = new Thread(r, name);
    t.start();
    while(t.getState() != state)
        Thread.sleep(1);
    return t;
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32485#discussion_r3854355962

Reply via email to