Class TimedExecutor


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

      • withCachedThreadPool

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

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

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

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

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

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

        public void dispose()