Class SharedExecutors


  • public final class SharedExecutors
    extends java.lang.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.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_POOL_SIZE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.ExecutorService getPoolThreadExecutor()
      Returns the shared thread pool executor.
      static java.util.concurrent.ExecutorService getSingleThreadExecutor()
      Returns the shared single thread executor.
      static java.util.Timer getTimer()
      Returns the shared timer.
      static void setMetricsService​(MetricsService metricsService)
      Enables or disables calculation of the pool performance metrics.
      static void setPoolSize​(int poolSize)
      Sets the shared thread pool size.
      static void shutdown()
      Shuts down all shared timers and executors and therefore should be called only by the framework.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSingleThreadExecutor

        public static java.util.concurrent.ExecutorService getSingleThreadExecutor()
        Returns the shared single thread executor.
        Returns:
        shared single thread executor
      • getPoolThreadExecutor

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

        public static java.util.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.