Tracking Executing Threads <p>I am trying to figure out how I can track all the threads that my application is spawning. Initially, I thought I had it figured out using a CyclicBarrier, however I am seeing threads executing after my await call.</p> <p>Below is the working pseudo code:</p> <pre><code>public class ThreadTesterRunner { public static void main(String[] args) throws InterruptedException { final CyclicBarrier cb = new CyclicBarrier(1); ThreadRunner tr = new ThreadRunner(cb); Thread t = new Thread(tr, "Thread Runner"); t.start(); boolean process = true; // wait until all threads process, then print reports while (process){ if(tr.getIsFinished()){ System.out.println("Print metrics"); process = false; } Thread.sleep(1000); } } } class ThreadRunner implements Runnable { static int timeOutTime = 2; private ExecutorService executorService = Executors.newFixedThreadPool(10); private final CyclicBarrier barrier; private boolean isFinished=false; public ThreadRunner(CyclicBarrier cb) { this.barrier = cb; } public void run(){ try { boolean stillLoop = true; int i = 0; while (stillLoop){ int size; Future&lt;Integer&gt; future = null; try { future = executorService.submit(new Reader()); // sleeps size = future.get(); } catch (InterruptedException | ExecutionException ex) { // handle Errs } if(i == 3){ stillLoop = false; this.barrier.await(); this.isFinished=true; } //System.out.println("i = "+i+" Size is: "+size+"\r"); i++; } } catch (InterruptedException | BrokenBarrierException e1) { e1.printStackTrace(); } } public boolean getIsFinished(){ return this.isFinished; } } class Reader implements Callable { private ExecutorService executorService = Executors.newFixedThreadPool(1); @Override public Object call() throws Exception { System.out.println("Reading..."); Thread.sleep(2000); executorService.submit(new Writer()); return 1000; } } class Writer implements Callable { @Override public Void call() throws Exception { Thread.sleep(4000); System.out.println("Wrote"); return null; } } </code></pre> <p>Can anyone suggest a way to ONLY print "print metrics" after all threads have run?</p>