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.
        shared single thread executor
      • getPoolThreadExecutor

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

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

        public static void setPoolSize​(int poolSize)
        Sets the shared thread pool size.
        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.
        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.