Class SharedScheduledExecutors


  • public final class SharedScheduledExecutors
    extends Object
    Utility for managing a set of shared execution resources, such as a single thread scheduled executor and thread pool scheduled executor for use by various parts of the platform or by applications.

    Whenever possible, use of these shared resources is encouraged over creating separate ones.

    • Method Detail

      • getSingleThreadExecutor

        public static SharedScheduledExecutorService getSingleThreadExecutor()
        Returns the shared scheduled single thread executor.
        Returns:
        shared scheduled single thread executor
      • newTimeout

        public static ScheduledFuture<?> newTimeout​(Runnable task,
                                                    long delay,
                                                    TimeUnit unit)
        Executes one-shot timer task on shared thread pool.
        Parameters:
        task - timer task to execute
        delay - before executing the task
        unit - of delay
        Returns:
        a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion
      • getPoolThreadExecutor

        public static SharedScheduledExecutorService getPoolThreadExecutor()
        Returns the shared scheduled thread pool executor.
        Returns:
        shared scheduled executor pool
      • setPoolSize

        public static void setPoolSize​(int poolSize)
        Configures the shared scheduled thread pool size.
        Parameters:
        poolSize - new pool size
      • shutdown

        public static void shutdown()
        Shuts down all shared scheduled executors. This is not intended to be called by application directly.