I am posed with the following problem: I need to split work across multiple threads for perfomance reasons, but I am not sure what approach to take.
Firstly, the tas
I shall add a proposal that is in my eyes more elegant than creating a whole new class for your parametrized Callable. My solution is a method that returns a Callable instance:
Callable expensive(final String param) {
return new Callable() { public String call() {
return expensiveMethod(param);
}};
}
This even makes client code more palatable:
final Future f1 = executor.submit(expensive("param1"));