wsyy
asked on
Multiple ExecutorService?
Hi,
I want to use multiple ExecutorServices, as follow:
Map<String, ExecutorService> ess;
for(String category: categories){
ExecutorService es=ess.get(category);
for(....){
es.execute(some job);
}
executor.shutdown();
while (!executor.isTerminated()) { }
//do some cleaning up here
}
I wonder:
1) is this a right framework?
2) I want to put things to work as soon as possible in the outer for loop. But the cleanup can take a long time to finish. How to solve this dilemma.
I want to use multiple ExecutorServices, as follow:
Map<String, ExecutorService> ess;
for(String category: categories){
ExecutorService es=ess.get(category);
for(....){
es.execute(some job);
}
executor.shutdown();
while (!executor.isTerminated())
//do some cleaning up here
}
I wonder:
1) is this a right framework?
2) I want to put things to work as soon as possible in the outer for loop. But the cleanup can take a long time to finish. How to solve this dilemma.
DO you need the clean up to be finished by the time you intiate jobs for new executor ?
If not, maybe you could have one more excutor service which will be responsible for clean up jobs? And hopefully you could have it the same for all categories
ASKER
I don't need the cleanup to be finished by the time of initiating the new executorserivce.
How can I create one more executor service? It is desirable that all cleanup be done after all the services are completed.
How can I create one more executor service? It is desirable that all cleanup be done after all the services are completed.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.