@Override
    public ID createChannel() {
        checkState(!isShutdown.get(), "File channel manager has shutdown.");

        int num = (int) (nextPath.getAndIncrement() % paths.length);
        return new ID(paths[num], num, random);
    }
@Test
    void testFairness() throws Exception {
        String directory1 =
                TempDirUtils.newFolder(temporaryFolder).getAbsoluteFile().getAbsolutePath();
        String directory2 =
                TempDirUtils.newFolder(temporaryFolder).getAbsoluteFile().getAbsolutePath();

        try (FileChannelManager fileChannelManager =
                new FileChannelManagerImpl(new String[] {directory1, directory2}, "test")) {
            int numChannelIDs = 100000;
            AtomicInteger counter1 = new AtomicInteger();
            AtomicInteger counter2 = new AtomicInteger();

            int numThreads = 10;
            Thread[] threads = new Thread[numThreads];
            for (int i = 0; i < numThreads; ++i) {
                threads[i] =
                        new Thread(
                                () -> {
                                    for (int j = 0; j < numChannelIDs; ++j) {
                                        FileIOChannel.ID channelID =
                                                fileChannelManager.createChannel();
                                        if (channelID.getPath().startsWith(directory1)) {
                                            counter1.incrementAndGet();
                                        } else {
                                            counter2.incrementAndGet();
                                        }
                                    }
                                });
                threads[i].start();
            }

            for (int i = 0; i < numThreads; ++i) {
                threads[i].join();
            }

            assertThat(counter2).hasValue(counter1.get());
        }
    }