Class DefaultThreadPool


  • public class DefaultThreadPool
    extends Object
    A thread pool that allows to execute tasks using pooled threads in order to ease the thread creation overhead.
    Author:
    Felix Project Team
    • Constructor Detail

      • DefaultThreadPool

        public DefaultThreadPool​(int poolSize,
                                 boolean syncThreads)
        Create a new pool.
        Parameters:
        poolSize - The size of the pool
        syncThreads - Sync or async pool
    • Method Detail

      • configure

        public void configure​(int poolSize)
        Configure a new pool size.
        Parameters:
        poolSize - The pool size
      • getPoolSize

        public int getPoolSize()
        Returns current pool size.
        Returns:
        The pool size
      • close

        public void close()
        Close the pool i.e, stop pooling threads. Note that subsequently, task will still be executed but no pooling is taking place anymore.
      • executeTask

        public boolean executeTask​(Runnable task)
        Execute the task in a free thread or create a new one.
        Parameters:
        task - The task to execute
        Returns:
        true if the task execution could be scheduled, false otherwise.