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 IThreadPool
threadpool
The 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 void
addFinishListener(IChangeListener<java.lang.Void> listener)
Add a finished 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.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:
shutdownService
in interfaceIInternalService
- Overrides:
shutdownService
in 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:
execute
in 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:
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
public void addFinishListener(IChangeListener<java.lang.Void> listener)
Add a finished listener.- Specified by:
addFinishListener
in interfaceIThreadPool
-
-