private void executeTasksSimultaneouslyWithBarrier(Runnable... tasks) throws InterruptedException {
  CountDownLatch latch=new CountDownLatch(tasks.length);
  for (  Runnable task : tasks) {
    executor.execute(null);
  }
  latch.await();
}

private void executeTasksSimultaneouslyWithBarrier ( Runnable ... tasks ) throws InterruptedException { CountDownLatch latch = new CountDownLatch ( tasks . length ) ; for ( Runnable task : tasks ) { executor . execute ( null ) ; } latch . await ( ) ; }
runs given tasks simultaneously and wait until they finish .
