Class ThreadPoolManager


  • public class ThreadPoolManager
    extends Object

    This class provides a general mechanism to create thread pools. In general, no code of openHAB should deal with its own pools, but rather use this class. The created thread pools have named threads, so that it is easy to find them in the debugger. Additionally, it is possible to configure the pool sizes through the configuration admin service, so that solutions have the chance to tweak the pool sizes according to their needs.

    The configuration can be done as
    org.eclipse.smarthome.threadpool:<poolName>=<poolSize>
    All threads will time out after THREAD_TIMEOUT.

    Author:
    Kai Kreuzer - Initial contribution
    • Field Detail

      • THREAD_POOL_NAME_COMMON

        public static final String THREAD_POOL_NAME_COMMON
        The common thread pool is reserved for occasional, light weight tasks that run quickly, and use little resources to execute. Tasks that do not fit into this category should setup their own dedicated pool or permanent thread.
        See Also:
        Constant Field Values
      • DEFAULT_THREAD_POOL_SIZE

        protected static final int DEFAULT_THREAD_POOL_SIZE
        See Also:
        Constant Field Values
    • Constructor Detail

      • ThreadPoolManager

        public ThreadPoolManager()
    • Method Detail

      • getScheduledPool

        public static ScheduledExecutorService getScheduledPool​(String poolName)
        Returns an instance of a scheduled thread pool service. If it is the first request for the given pool name, the instance is newly created.
        Parameters:
        poolName - a short name used to identify the pool, e.g. "discovery"
        Returns:
        an instance to use
      • getPool

        public static ExecutorService getPool​(String poolName)
        Returns an instance of a cached thread pool service. If it is the first request for the given pool name, the instance is newly created.
        Parameters:
        poolName - a short name used to identify the pool, e.g. "discovery"
        Returns:
        an instance to use
      • getConfig

        protected static int getConfig​(String poolName)