Link to home
Start Free TrialLog in
Avatar of wsyy
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.
Avatar of for_yan
for_yan
Flag of United States of America image

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
Avatar of wsyy
wsyy

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.
SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial