The problem with your performance, apparently, is that the individual tasks are too small, so most of the time is spent on synchronizing and queuing the tasks themselves. One thing to consider is not to generate a large stream of small tasks, but to deliver to each work stream an average set of tasks that it will comment on with the answer.
For example, instead of repeating in your loop with the first thread iterating # 0, the next thread iterating # 1, ... I will have the first thread iterating from # 0 to # 999 or some. They should work independently and annotate the Job class with an answer to their calculations. Then at the end they can return the entire collection of assignments that were completed as Future .
Your Job class might look something like this:
public class Job { Collection<RealVector> dataCollection; Collection<SomeAnswer> answerCollection = new ArrayList<SomeAnswer>(); public void run() { for (RealVector d : dataCollection) {
Gray
source share