public void run() throws Exception {
    try {

      CountDownLatch countDownLatch = new CountDownLatch(this.tasks);
      for (int i = 0; i < this.tasks; i++) {
        addTask(i, countDownLatch);
      }
      // Wait for the tasks to finish
      countDownLatch.await();
    } finally {
      try {
        // Calling close() will stop metric reporting
        this.context.close();
      } finally {
        this.executor.shutdownNow();
      }
    }
  }
public void run ( ) throws Exception { try { CountDownLatch countDownLatch = new CountDownLatch ( this . tasks ) ; for ( int i = 0 ; i < this . tasks ; i ++ ) { addTask ( i , countDownLatch ) ; } countDownLatch . await ( ) ; } finally { try { this . context . close ( ) ; } finally { this . executor . shutdownNow ( ) ; } } }
Run the example.