CountingFactorizer extends GenericServlet implements Servlet { public long getCount() { return count.get(); }  long getCount(); void service(ServletRequest req, ServletResponse resp);  }
@Test public void testFacotorize() { final int MAX_ITERATIONS = 1000000; CountingFactorizer factorizer = new CountingFactorizer(); ExecutorService executor = Executors.newFixedThreadPool(20); for (int i = 0; i < MAX_ITERATIONS; i++) { Runnable worker = new FactorizerWorkerThread(factorizer); executor.execute(worker); } executor.shutdown(); while (!executor.isTerminated()) { } assertEquals(MAX_ITERATIONS, factorizer.getCount()); }