The problem is not with the thread pool implementation. You try and get one Future
at a time, so your program is essentially single threaded.
What you should do is create a Collection
of your Callable
s and use:
final List<Future<Set<Fragment>>> results
= executor.invokeAll(yourCollectionOfCallables);
Then loop over your results
. The thread pool will do its best to start threads with new tasks when one task is complete; what is more you are guaranteed that all tasks have completed (successfully or not) when you have iterated over all the list.