@Test public void testExecute() { Runnable runnable = mock(Runnable.class); underTest.execute(runnable); verify(runnable).run(); }
@Override public void execute(final Runnable runnable) { final Integer recursionDepth = recursionDepthPerThread.get(); recursionDepthPerThread.set(recursionDepth + 1); if (recursionDepth + 1 <= maxRecursionDepth) { runnable.run(); } else { executorService.submit(runnable); } recursionDepthPerThread.set(recursionDepth); }
RecursionSafeCaller implements Caller { @Override public void execute(final Runnable runnable) { final Integer recursionDepth = recursionDepthPerThread.get(); recursionDepthPerThread.set(recursionDepth + 1); if (recursionDepth + 1 <= maxRecursionDepth) { runnable.run(); } else { executorService.submit(runnable); } recursionDepthPerThread.set(recursionDepth); } }
RecursionSafeCaller implements Caller { @Override public void execute(final Runnable runnable) { final Integer recursionDepth = recursionDepthPerThread.get(); recursionDepthPerThread.set(recursionDepth + 1); if (recursionDepth + 1 <= maxRecursionDepth) { runnable.run(); } else { executorService.submit(runnable); } recursionDepthPerThread.set(recursionDepth); } RecursionSafeCaller(
      ExecutorService executorService, Caller caller, long maxRecursionDepth
  );  RecursionSafeCaller(ExecutorService executorService, Caller caller); }
RecursionSafeCaller implements Caller { @Override public void execute(final Runnable runnable) { final Integer recursionDepth = recursionDepthPerThread.get(); recursionDepthPerThread.set(recursionDepth + 1); if (recursionDepth + 1 <= maxRecursionDepth) { runnable.run(); } else { executorService.submit(runnable); } recursionDepthPerThread.set(recursionDepth); } RecursionSafeCaller(
      ExecutorService executorService, Caller caller, long maxRecursionDepth
  );  RecursionSafeCaller(ExecutorService executorService, Caller caller); @Override void referenceLeaked(final Object reference, final StackTraceElement[] stack); @Override void execute(final Runnable runnable); }
RecursionSafeCaller implements Caller { @Override public void execute(final Runnable runnable) { final Integer recursionDepth = recursionDepthPerThread.get(); recursionDepthPerThread.set(recursionDepth + 1); if (recursionDepth + 1 <= maxRecursionDepth) { runnable.run(); } else { executorService.submit(runnable); } recursionDepthPerThread.set(recursionDepth); } RecursionSafeCaller(
      ExecutorService executorService, Caller caller, long maxRecursionDepth
  );  RecursionSafeCaller(ExecutorService executorService, Caller caller); @Override void referenceLeaked(final Object reference, final StackTraceElement[] stack); @Override void execute(final Runnable runnable);  }