Java 17 added RandomGenerator interface. However, existing method Collections.shuffle accepts old java.util.Random class. While since Java 19, it's possible to use Random.from(RandomGenerator) wrapper, it would be more convenient to provide direct overload shuffle(List<?> list, RandomGenerator rnd).
As we are here, it would also be nice to get rid of Collections.r static random generator which is used by default, and use ThreadLocalRandom instead. This will reduce the contention if shuffle() without explicit random generator is called from different threads concurrently. ------------- Commit messages: - 8294693: Add Collections.shuffle overload that accepts RandomGenerator interface Changes: https://git.openjdk.org/jdk/pull/10520/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10520&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8294693 Stats: 128 lines in 2 files changed: 121 ins; 3 del; 4 mod Patch: https://git.openjdk.org/jdk/pull/10520.diff Fetch: git fetch https://git.openjdk.org/jdk pull/10520/head:pull/10520 PR: https://git.openjdk.org/jdk/pull/10520