Trying to invoke Future <ExecutorCompletionService>

hi guys

I have

ExecutorService executor = Executors.newFixedThreadPool(10);		
CompletionService<List<Object>> exservice = new ExecutorCompletionService<List<Object>>(executor);
Future<List<Object>> future = null;
if(count  > 0){		
for(int t = 0; t < 10; t++){		 
Callable<List<Object>> task = new Callable<List<Object>>(){		 
public List<Object> call(){	
try{		
list = getSummaryList();		 
for(Summary summ : list){  
if (summ != null) {
processor.process(summ);
} 
}//end for	
}catch(Exception e){
e.printStackTrace();
}
return summaryList; //end call()
	}
}; 	
future = exservice.submit(task);
}
//shutdown the process
if(future.isDone()){
System.exit(0); 
}
}

Open in new window


I put a break point on this line>>if(future.isDone()){
but it never comes here , trying to understand what could be the reason.

Any help would be greatly appreciated.
thanks.
royjaydAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
IS count > 0?

btw, you're more likely to get help if you indent your code properly
0
royjaydAuthor Commented:
Count is > 0 and processor.process(summ); is also invoked 10 times.

ExecutorService executor = Executors.newFixedThreadPool(10);		
CompletionService<List<Object>> exservice = new ExecutorCompletionService<List<Object>>(executor);
Future<List<Object>> future = null;
if(count  > 0){		
	for(int t = 0; t < 10; t++){		 
		Callable<List<Object>> task = new Callable<List<Object>>(){		 
		public List<Object> call(){	
		try{		
			list = getSummaryList();		 
			for(Summary summ : list){  
			if (summ != null) {
				processor.process(summ);
			} 
			}//end for	
		}catch(Exception e){
			e.printStackTrace();
		}
		return summaryList; //end call()
			}
		}; 	
		future = exservice.submit(task);
	}
	     //shutdown the process
	     if(future.isDone()){
 	     System.exit(0); 
	}
} 

Open in new window

0
CEHJCommented:
Your code is confusing and possibly confused.

What is 'Summary' and usually how many items are in List 'list'?
Why are you not using Callable<List<Summary>>?
0
krakatoaCommented:
Did you call 'run()' ?
0
dpearsonCommented:
If this is basically all of the code you need to add a call to wait for the threads to do their work.

Check out either awaitTermination() or invokeAll()

Doug
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.