Class DefaultThreadPool

java.lang.Object
org.apache.felix.eventadmin.impl.tasks.DefaultThreadPool

public class DefaultThreadPool
extends java.lang.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 Summary

    Constructors 
    Constructor Description
    DefaultThreadPool​(int poolSize, boolean syncThreads)
    Create a new pool.
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the pool i.e, stop pooling threads.
    void configure​(int poolSize)
    Configure a new pool size.
    boolean executeTask​(java.lang.Runnable task)
    Execute the task in a free thread or create a new one.
    int getPoolSize()
    Returns current pool size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultThreadPool

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

    • 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​(java.lang.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.