public class JavaThreadPool extends java.lang.Object implements IThreadPool
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ExecutorService |
executor
The executor service.
|
protected java.util.List<IChangeListener<java.lang.Void>> |
listeners
The finished listeners.
|
protected Future<java.lang.Void> |
shutdown
Future used for performing shutdown.
|
Constructor and Description |
---|
JavaThreadPool(boolean daemon)
Create a new ThreadPool5.
|
Modifier and Type | Method and Description |
---|---|
void |
addFinishListener(IChangeListener<java.lang.Void> listener)
Add a finish listener;
|
void |
dispose()
Shutdown the thread pool.
|
void |
execute(java.lang.Runnable task)
Execute a task in its own thread.
|
void |
executeForever(java.lang.Runnable task)
Execute a task in its own thread.
|
boolean |
isRunning()
Test if the thread pool is running.
|
protected void |
notifyFinishListeners()
Notify the finish listeners.
|
protected java.util.concurrent.ExecutorService executor
protected java.util.List<IChangeListener<java.lang.Void>> listeners
protected Future<java.lang.Void> shutdown
public void execute(java.lang.Runnable task)
execute
in interface IThreadPool
task
- The task to execute.public void executeForever(java.lang.Runnable task)
executeForever
in interface IThreadPool
task
- The task to execute.public void dispose()
dispose
in interface IThreadPool
public boolean isRunning()
isRunning
in interface IThreadPool
public void addFinishListener(IChangeListener<java.lang.Void> listener)
addFinishListener
in interface IThreadPool
protected void notifyFinishListeners()