Class TimedExecutor


  • public class TimedExecutor
    extends Object
    Utility class to execute tasks in background with timeout.
    Since:
    8.1
    • Method Detail

      • withCachedThreadPool

        @NotNull
        public static TimedExecutor withCachedThreadPool​(@NotNull
                                                         String name)
      • withCachedThreadPool

        @NotNull
        public static TimedExecutor withCachedThreadPool​(@NotNull
                                                         String name,
                                                         long keepAliveMilliseconds)
      • withSingleThreadPool

        @NotNull
        public static TimedExecutor withSingleThreadPool​(@NotNull
                                                         String name)
      • withFixedThreadPool

        @NotNull
        public static TimedExecutor withFixedThreadPool​(int threadCount,
                                                        @NotNull
                                                        String name)
      • execute

        @Nullable
        public <T> T execute​(long timeoutMilliseconds,
                             @NotNull
                             Callable<T> task)
      • execute

        @Nullable
        public <T,​E extends Throwable> T execute​(long timeoutMilliseconds,
                                                       @NotNull
                                                       Class<E> exceptionClazz,
                                                       @NotNull
                                                       Callable<T> task)
                                                throws E extends Throwable
        Throws:
        E extends Throwable
      • dispose

        public void dispose()