RFR: 8314515: java/util/concurrent/SynchronousQueue/Fairness.java failed with "Error: fair=false i=8 j=0"

Viktor Klang duke at openjdk.org
Fri Aug 18 08:20:31 UTC 2023


On Thu, 17 Aug 2023 22:35:39 GMT, Martin Buchholz <martin at openjdk.org> wrote:

> The usual tiny improvements, with no guarantee that the intermittent test failure is actually fixed.

test/jdk/java/util/concurrent/SynchronousQueue/Fairness.java line 41:

> 39:         throws Throwable
> 40:     {
> 41:         int threadCount = ThreadLocalRandom.current().nextInt(2, 8);

@Martin-Buchholz I'm a bit weary about making the number of threads random—might make it tricky to get to reproduce if the test fails?

test/jdk/java/util/concurrent/SynchronousQueue/Fairness.java line 55:

> 53:             Thread t = new Thread(put);
> 54:             t.start();
> 55:             ts.add(t);

@Martin-Buchholz Any specific reason to add the thread *after* it has been started?

test/jdk/java/util/concurrent/SynchronousQueue/Fairness.java line 70:

> 68:                                               fair, i, threadCount, j));
> 69:         }
> 70:         for (Thread t : ts) t.join();

@Martin-Buchholz Makes a lot of sense to make sure that all threads have terminated before exiting the test 👍

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15337#discussion_r1298155867
PR Review Comment: https://git.openjdk.org/jdk/pull/15337#discussion_r1298157572
PR Review Comment: https://git.openjdk.org/jdk/pull/15337#discussion_r1298158247


More information about the core-libs-dev mailing list