ParallelRunner { public void parallelRun(Iterable<? extends Runnable> tasks, int numThreads) { parallelRun(tasks.iterator(), numThreads); } ParallelRunner(ExecutorService executor, String defaultNamePrefix);  ParallelRunner(ExecutorService executor); void parallelRunExt(
      Iterable<? extends ExtRunnable<E>> tasks,
      int numThreads,
      ExceptionHandler<E> exceptionHandler); void parallelRunExt(
      Iterator<? extends ExtRunnable<E>> tasksIter,
      int numThreads,
      ExceptionHandler<E> exceptionHandler); void parallelRunExt(
      Iterable<? extends ExtRunnable<E>> tasks,
      int numThreads,
      ExceptionHandler<E> exceptionHandler,
      String baseName); void parallelRunExt(
      Iterator<? extends ExtRunnable<E>> tasksIter,
      int numThreads,
      ExceptionHandler<E> exceptionHandler,
      String baseName); void parallelRun(Iterable<? extends Runnable> tasks, int numThreads); void parallelRun(Iterator<? extends Runnable> tasksIter, int numThreads); void parallelRun(Iterable<? extends Runnable> tasks, int numThreads, String baseName); void parallelRun(Iterator<? extends Runnable> tasksIter, int numThreads, String baseName);  }
@Test(groups = {"fast", "local"}) public void testThreadName() throws Exception { String threadNamePrefix = "sloth"; AtomicBoolean hasNextRef = new AtomicBoolean(true); AtomicReference<String> errorMessage = new AtomicReference<>(); CountDownLatch latch = new CountDownLatch(1); BlockingQueue<Runnable> taskQueue = new LinkedBlockingDeque<>(); taskQueue.add( () -> { String threadName = Thread.currentThread().getName(); if (!threadName.contains(threadNamePrefix)) { errorMessage.set( String.format("threadName mistmatch [%s] vs [%s]", threadNamePrefix, threadName)); } latch.countDown(); }); ThreadHelper threadHelper = new ThreadHelper(); Thread slothThread = threadHelper.doInThread( () -> parallelRunner.parallelRun(taskQueue, 2, threadNamePrefix), "parallel-runner-sheppard"); latch.await(); if (errorMessage.get() != null) { Assert.fail(errorMessage.get()); } hasNextRef.set(false); slothThread.join(); }