ExecutorService - scaling
Posted
by
Stanciu Alexandru-Marian
on Stack Overflow
See other posts from Stack Overflow
or by Stanciu Alexandru-Marian
Published on 2011-11-29T07:50:48Z
Indexed on
2011/11/29
9:50 UTC
Read the original article
Hit count: 386
java
I am trying to write a program in Java using ExecutorService and it's function invokeAll. My question is: does the invokeAll functions solve the tasks simultaneously? I mean, if i have two processors, there will be two workers in the same time? Because a can't make it to scale correct. It takes the same time to complete the problem if i give newFixedThreadPool(2) or 1.
List<Future<PartialSolution>> list = new ArrayList<Future<PartialSolution>>();
Collection<Callable<PartialSolution>> tasks = new ArrayList<Callable<PartialSolution>>();
for(PartialSolution ps : wp)
{
tasks.add(new Map(ps, keyWords));
}
list = executor.invokeAll(tasks);
Map is a class that implements Callable and wp is a vector of Partial Solutions, a class that holds some informations in different times.
Why doesn't it scale? What could be the problem?
Thank you, Alex
© Stack Overflow or respective owner