@Test(expectedExceptions = RuntimeException.class) public void testNewThreadFactory() throws InterruptedException { Logger logger = Mockito.mock(Logger.class); ThreadFactory threadFactory = ExecutorsUtils.newThreadFactory(Optional.of(logger)); final RuntimeException runtimeException = new RuntimeException(); Thread thread = threadFactory.newThread(new Runnable() { @Override public void run() { throw runtimeException; } }); thread.setName("foo"); String errorMessage = String.format("Thread %s threw an uncaught exception: %s", thread, runtimeException); Mockito.doThrow(runtimeException).when(logger).error(errorMessage, runtimeException); thread.run(); }
public static ThreadFactory newThreadFactory(Optional<Logger> logger) { return newThreadFactory(logger, Optional.<String>absent()); }
ExecutorsUtils { public static ThreadFactory newThreadFactory(Optional<Logger> logger) { return newThreadFactory(logger, Optional.<String>absent()); } }
ExecutorsUtils { public static ThreadFactory newThreadFactory(Optional<Logger> logger) { return newThreadFactory(logger, Optional.<String>absent()); }  }
ExecutorsUtils { public static ThreadFactory newThreadFactory(Optional<Logger> logger) { return newThreadFactory(logger, Optional.<String>absent()); }  static ThreadFactory defaultThreadFactory(); static ThreadFactory newThreadFactory(Optional<Logger> logger); static ThreadFactory newThreadFactory(Optional<Logger> logger, Optional<String> nameFormat); static ThreadFactory newDaemonThreadFactory(Optional<Logger> logger, Optional<String> nameFormat); static ListeningExecutorService loggingDecorator(ExecutorService executorService); static ListeningScheduledExecutorService loggingDecorator(ScheduledExecutorService scheduledExecutorService); static Runnable loggingDecorator(Runnable runnable); static Callable<T> loggingDecorator(Callable<T> callable); static void shutdownExecutorService(ExecutorService executorService, Optional<Logger> logger, long timeout,
      TimeUnit unit); static void shutdownExecutorService(ExecutorService executorService, Optional<Logger> logger); static List<T> parallelize(final List<F> list, final Function<F, T> function, int threadCount,
      int timeoutInSecs, Optional<Logger> logger); }
ExecutorsUtils { public static ThreadFactory newThreadFactory(Optional<Logger> logger) { return newThreadFactory(logger, Optional.<String>absent()); }  static ThreadFactory defaultThreadFactory(); static ThreadFactory newThreadFactory(Optional<Logger> logger); static ThreadFactory newThreadFactory(Optional<Logger> logger, Optional<String> nameFormat); static ThreadFactory newDaemonThreadFactory(Optional<Logger> logger, Optional<String> nameFormat); static ListeningExecutorService loggingDecorator(ExecutorService executorService); static ListeningScheduledExecutorService loggingDecorator(ScheduledExecutorService scheduledExecutorService); static Runnable loggingDecorator(Runnable runnable); static Callable<T> loggingDecorator(Callable<T> callable); static void shutdownExecutorService(ExecutorService executorService, Optional<Logger> logger, long timeout,
      TimeUnit unit); static void shutdownExecutorService(ExecutorService executorService, Optional<Logger> logger); static List<T> parallelize(final List<F> list, final Function<F, T> function, int threadCount,
      int timeoutInSecs, Optional<Logger> logger); static final long EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT; static final TimeUnit EXECUTOR_SERVICE_SHUTDOWN_TIMEOUT_TIMEUNIT; }