Package org.apache.felix.eventadmin.impl.tasks

## Class DefaultThreadPool

- java.lang.Object
- - org.apache.felix.eventadmin.impl.tasks.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 Summary

Constructors
`DefaultThreadPool​(int poolSize, boolean syncThreads)` Create a new pool.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Close the pool i.e, stop pooling threads.
`void` `configure​(int poolSize)` Configure a new pool size.
`boolean` `executeTask​(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 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.