Class SharedExecutors


  • public final class SharedExecutors
    extends Object
    Utility for managing a set of shared execution resources, such as a timer, single thread executor and thread pool 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 ExecutorService getSingleThreadExecutor()
        Returns the shared single thread executor.
        Returns:
        shared single thread executor
      • getPoolThreadExecutor

        public static ExecutorService getPoolThreadExecutor()
        Returns the shared thread pool executor.
        Returns:
        shared executor pool
      • getTimer

        public static Timer getTimer()
        Returns the shared timer.
        Returns:
        shared timer
      • setPoolSize

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

        public static void setMetricsService​(MetricsService metricsService)
        Enables or disables calculation of the pool performance metrics. If the metrics service is not null metric collection will be enabled; otherwise it will be disabled.
        Parameters:
        metricsService - optional metric service
      • shutdown

        public static void shutdown()
        Shuts down all shared timers and executors and therefore should be called only by the framework.