I am having trouble, however, with letting a
thread
know at which place in thearray
it should store its result. Should I define my ownThreadFactory
?
No need for that. The interfaces used by executors (Runnable
and Callable
) are run by threads, and you can pass whatever arguments to implementations you want to pass (for instance, an array, a begin index and an end index).
A ThreadPoolExecutor
is indeed a good solution. Also look at FutureTask
if you have runnables bearing results.