Package jadex.concurrent
Class JavaThreadPool
java.lang.Object
jadex.concurrent.JavaThreadPool
- All Implemented Interfaces:
IThreadPool
A thread pool based on the java.util.concurrent package.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFinishListener
(jadex.common.IChangeListener<Void> listener) Add a finish listener;void
dispose()
Shutdown the thread pool.void
Execute a task in its own thread.void
executeForever
(Runnable task) Execute a task in its own thread.boolean
Test if the thread pool is running.protected void
Notify the finish listeners.
-
Field Details
-
executor
The executor service. -
listeners
The finished listeners. -
shutdown
Future used for performing shutdown.
-
-
Constructor Details
-
JavaThreadPool
public JavaThreadPool(boolean daemon) Create a new ThreadPool5.
-
-
Method Details
-
execute
Execute a task in its own thread.- Specified by:
execute
in interfaceIThreadPool
- Parameters:
task
- The task to execute.
-
executeForever
Execute a task in its own thread. The pool expects the thread executing the task to never return. Preferably use this method if you want to permanently retrieve a thread e.g. for repeated blocking operations.- Specified by:
executeForever
in interfaceIThreadPool
- Parameters:
task
- The task to execute.
-
dispose
public void dispose()Shutdown the thread pool.- Specified by:
dispose
in interfaceIThreadPool
-
isRunning
public boolean isRunning()Test if the thread pool is running.- Specified by:
isRunning
in interfaceIThreadPool
-
addFinishListener
Add a finish listener;- Specified by:
addFinishListener
in interfaceIThreadPool
-
notifyFinishListeners
protected void notifyFinishListeners()Notify the finish listeners.
-