
public class ThreadManager extends Object
| Modifier and Type | Field and Description |
|---|---|
private ExecutorService |
cached
The cached executor for services.
|
private ExecutorService |
fixed
The fixed executor for tasks.
|
| Constructor and Description |
|---|
ThreadManager()
Dfault constructor.
|
ThreadManager(int cores) |
| Modifier and Type | Method and Description |
|---|---|
Future<?> |
addService(AbstractService thread) |
void |
closeAndWait(long timeout)
Shuts down all the services and tasks added.
|
<K> Future<K> |
execute(Callable<K> thread) |
void |
execute(Object obj,
String method,
Object[] args)
Deprecated.
|
Future<?> |
execute(Runnable thread)
This method will schedule a task for the execution in the
FixedThreadPool.
|
private final ExecutorService cached
private final ExecutorService fixed
public ThreadManager()
public ThreadManager(int cores)
cores - the number of threads for the tasks executor.public Future<?> addService(AbstractService thread)
thread - The service to add to the CachedThreadPoolpublic void closeAndWait(long timeout)
timeout - maximum time for this operation, in milliseconds.public <K> Future<K> execute(Callable<K> thread)
K - parameter type of the Futurethread - The Callable to schedule@Deprecated public void execute(Object obj, String method, Object[] args) throws NoSuchMethodException
obj - the object within which invoke the methodmethod - the method to invokeargs - arguments for the methodNoSuchMethodException - if the method does not exist