Class AdvancedThreadPoolService
- java.lang.Object
- 
- jadex.bridge.service.BasicService
- 
- jadex.platform.service.threadpool.AdvancedThreadPoolService
 
 
- 
- All Implemented Interfaces:
- IInternalService,- IService,- IDaemonThreadPoolService,- IThreadPoolService,- IThreadPool
 
 public class AdvancedThreadPoolService extends BasicService implements IThreadPoolService, IDaemonThreadPoolService A thread pool based on the java.util.concurrent package.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.concurrent.ExecutorServiceexecutorThe executor service.protected static MonitoredThreadPoolExecutorGLOBAL_EXECUTORThe global executor.protected java.util.List<IChangeListener<java.lang.Void>>listenersThe finished listeners.protected Future<java.lang.Void>shutdownFuture for pool shutdown.- 
Fields inherited from class jadex.bridge.service.BasicServiceidcnt, impltype, internalaccess, providerid, shutdowned, sid, started, type
 - 
Fields inherited from interface jadex.bridge.service.IServiceEMPTY_SERVICES
 
- 
 - 
Constructor SummaryConstructors Constructor Description AdvancedThreadPoolService(IComponentIdentifier provider, boolean daemon)Create a new ThreadPool.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFinishListener(IChangeListener<java.lang.Void> listener)Add a finish listener;voiddispose()Shutdown the thread pool.voidexecute(java.lang.Runnable task)Execute a task in its own thread.voidexecuteForever(java.lang.Runnable task)Execute a task in its own thread.booleanisRunning()Test if the thread pool is running.static voidmain(java.lang.String[] args)Test main.protected voidnotifyFinishListeners()Notify the finish listeners.IFuture<java.lang.Void>shutdown()Service shutdown.- 
Methods inherited from class jadex.bridge.service.BasicServicecreateServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getInvokeMethod, getMethodInfos, getMethodTimeout, getPropertyMap, getProviderId, getServiceId, hashCode, initNFProperties, invokeMethod, isValid, setComponentAccess, setPropertyMap, setServiceIdentifier, shutdownService, startService, toString
 
- 
 
- 
- 
- 
Field Detail- 
GLOBAL_EXECUTORprotected static volatile MonitoredThreadPoolExecutor GLOBAL_EXECUTOR The global executor.
 - 
executorprotected java.util.concurrent.ExecutorService executor The executor service.
 - 
listenersprotected java.util.List<IChangeListener<java.lang.Void>> listeners The finished listeners.
 - 
shutdownprotected Future<java.lang.Void> shutdown Future for pool shutdown.
 
- 
 - 
Constructor Detail- 
AdvancedThreadPoolServicepublic AdvancedThreadPoolService(IComponentIdentifier provider, boolean daemon) Create a new ThreadPool.
 
- 
 - 
Method Detail- 
executepublic void execute(java.lang.Runnable task) Execute a task in its own thread.- Specified by:
- executein interface- IThreadPool
- Parameters:
- task- The task to execute.
 
 - 
executeForeverpublic void executeForever(java.lang.Runnable task) 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 interface- IThreadPool
- Parameters:
- task- The task to execute.
 
 - 
shutdownpublic IFuture<java.lang.Void> shutdown() Service shutdown.- Returns:
- Null, when done.
 
 - 
disposepublic void dispose() Shutdown the thread pool.- Specified by:
- disposein interface- IThreadPool
 
 - 
isRunningpublic boolean isRunning() Test if the thread pool is running.- Specified by:
- isRunningin interface- IThreadPool
 
 - 
addFinishListenerpublic void addFinishListener(IChangeListener<java.lang.Void> listener) Add a finish listener;- Specified by:
- addFinishListenerin interface- IThreadPool
 
 - 
notifyFinishListenersprotected void notifyFinishListeners() Notify the finish listeners.
 - 
mainpublic static void main(java.lang.String[] args) Test main.
 
- 
 
-