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 TypeMethodDescriptionvoidaddFinishListener(jadex.common.IChangeListener<Void> listener) Add a finish listener;voiddispose()Shutdown the thread pool.voidExecute a task in its own thread.voidexecuteForever(Runnable task) Execute a task in its own thread.booleanTest if the thread pool is running.protected voidNotify 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:
executein 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:
executeForeverin interfaceIThreadPool- Parameters:
task- The task to execute.
-
dispose
public void dispose()Shutdown the thread pool.- Specified by:
disposein interfaceIThreadPool
-
isRunning
public boolean isRunning()Test if the thread pool is running.- Specified by:
isRunningin interfaceIThreadPool
-
addFinishListener
Add a finish listener;- Specified by:
addFinishListenerin interfaceIThreadPool
-
notifyFinishListeners
protected void notifyFinishListeners()Notify the finish listeners.
-