private void executeTaskNTimesSimultaneouslyWithBarrier(Runnable task,int times) throws InterruptedException {
  CountDownLatch latch=new CountDownLatch(times);
  for (int i=0; i < times; i++) {
    executor.execute(null);
  }
  latch.await();
}

private void executeTaskNTimesSimultaneouslyWithBarrier ( Runnable task , int times ) throws InterruptedException { CountDownLatch latch = new CountDownLatch ( times ) ; for ( int i = 0 ; i < times ; i ++ ) { executor . execute ( null ) ; } latch . await ( ) ; }
runs processes to do specified task simultaneously and wait until they finish .
