ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(10));
CountDownLatch startSignal = new CountDownLatch(1);
CountDownLatch helloDoneSignal = new CountDownLatch(5);
executor.execute(new HelloWorker(helloPort, "Fred", "", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "Barry", "Jameson", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "Harry", "", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "Rob", "Davidson", startSignal, helloDoneSignal));
executor.execute(new HelloWorker(helloPort, "James", "ServiceMix", startSignal, helloDoneSignal));
startSignal.countDown();
helloDoneSignal.await(60, TimeUnit.SECONDS);
executor.shutdownNow();
assertEquals("Not all invocations have completed", 0, helloDoneSignal.getCount());