@Test
public void testSafeCreateDirectoryMultiThreaded() throws InterruptedException {

    final int threadCount = 16;
    final AtomicInteger errorCount = new AtomicInteger();
    final Path directory = folder.getRoot().toPath().resolve("this/is/the/directory/for/all/of/my/downloads");
    final CountDownLatch latchStart = new CountDownLatch(threadCount);
    final CountDownLatch latchStop = new CountDownLatch(threadCount);
    for (int i = 0; i < threadCount; i++) {
        new Thread(() -> {
            latchStart.countDown();
            try {
                latchStart.await(10, TimeUnit.SECONDS);
                Path result = SW360AttachmentUtils.safeCreateDirectory(directory, true);
                if(!result.equals(directory)) {
                    errorCount.incrementAndGet();
                }
            } catch (InterruptedException | IOException e) {
                errorCount.incrementAndGet();
            }
            latchStop.countDown();
        }).start();
    }
    assertThat(latchStop.await(10, TimeUnit.SECONDS)).isTrue();
    assertThat(Files.isDirectory(directory)).isTrue();
    assertThat(errorCount.get()).isEqualTo(0);
}