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 voidclose()Close the pool i.e, stop pooling threads.voidconfigure(int poolSize)Configure a new pool size.booleanexecuteTask(java.lang.Runnable task)Execute the task in a free thread or create a new one.intgetPoolSize()Returns current pool size.
-
Constructor Details
-
DefaultThreadPool
public DefaultThreadPool(int poolSize, boolean syncThreads)Create a new pool.- Parameters:
poolSize- The size of the poolsyncThreads- 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:
trueif the task execution could be scheduled,falseotherwise.
-