Class ThreadPoolService
- java.lang.Object
-
- jadex.bridge.service.BasicService
-
- jadex.platform.service.threadpool.ThreadPoolService
-
- All Implemented Interfaces:
IInternalService,IService,IDaemonThreadPoolService,IThreadPoolService,IThreadPool
public class ThreadPoolService extends BasicService implements IThreadPoolService, IDaemonThreadPoolService
Service wrapper for a threadpool.
-
-
Field Summary
Fields Modifier and Type Field Description protected IThreadPoolthreadpoolThe threadpool.-
Fields inherited from class jadex.bridge.service.BasicService
idcnt, impltype, internalaccess, providerid, shutdowned, sid, started, type
-
Fields inherited from interface jadex.bridge.service.IService
EMPTY_SERVICES
-
-
Constructor Summary
Constructors Constructor Description ThreadPoolService(IThreadPool threadpool, IComponentIdentifier provider)Create a new threadpool service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFinishListener(IChangeListener<java.lang.Void> listener)Add a finished 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.IFuture<java.lang.Void>shutdownService()Shutdown the service.-
Methods inherited from class jadex.bridge.service.BasicService
createServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getInvokeMethod, getMethodInfos, getMethodTimeout, getPropertyMap, getProviderId, getServiceId, hashCode, initNFProperties, invokeMethod, isValid, setComponentAccess, setPropertyMap, setServiceIdentifier, startService, toString
-
-
-
-
Field Detail
-
threadpool
protected IThreadPool threadpool
The threadpool.
-
-
Constructor Detail
-
ThreadPoolService
public ThreadPoolService(IThreadPool threadpool, IComponentIdentifier provider)
Create a new threadpool service.
-
-
Method Detail
-
shutdownService
public IFuture<java.lang.Void> shutdownService()
Shutdown the service.- Specified by:
shutdownServicein interfaceIInternalService- Overrides:
shutdownServicein classBasicService- Returns:
- A future that is done when the service has completed its shutdown.
-
execute
public void execute(java.lang.Runnable task)
Execute a task in its own thread.- Specified by:
executein interfaceIThreadPool- Parameters:
task- The task to execute.
-
executeForever
public 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. Consider requesting the daemon version.- 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
public void addFinishListener(IChangeListener<java.lang.Void> listener)
Add a finished listener.- Specified by:
addFinishListenerin interfaceIThreadPool
-
-