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 Constructor Description DefaultThreadPool(int poolSize, boolean syncThreads)
Create a new pool.
-
Method Summary
All Methods Instance Methods Concrete Methods 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(Runnable task)
Execute the task in a free thread or create a new one.int
getPoolSize()
Returns current pool size.
-
-
-
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.
-
-