@SuppressFBWarnings("MDM_THREAD_YIELD") private void runTest(final RecyclingSupplier<ExpensiveTestObject> pool, final long sleepBetweenSubmit, final long deadlockTimeout) throws InterruptedException { Thread monitor = startDeadlockMonitor(pool, deadlockTimeout); ExecutorService execService = new LifoThreadPoolExecutorSQP("test", 10, 10, 5000, 1024, true); FailSafeExecutorImpl exec = new FailSafeExecutorImpl(execService); AsyncRetryExecutor policy = RetryPolicy.newBuilder() .withDefaultThrowableRetryPredicate().buildAsync(exec); int nrTests = 1000; Future<Integer>[] futures = new Future[nrTests]; for (int i = 0; i < nrTests; i++) { futures[i] = policy.submit(new TestCallable(pool, i)); Thread.sleep(sleepBetweenSubmit); } Pair<Map<Future, Object>, Exception> all = Futures.getAll(10000, futures); Exception ex = all.getSecond(); if (ex != null) { throw new RuntimeException(ex); } LOG.debug("Done({})", futures.length); monitor.interrupt(); monitor.join(); Thread.sleep(100); if (isDeadlock) { Assert.fail("deadlock detected"); } exec.close(); }