Your object is to replace:
tasks.add(new Callable<String>() {
public String call() throws Exception {
client.updateStats(surv).toString();
return surv.getId();
}
});
With
tasks.add(new Callable<String>() {
public String call() throws Exception {
doSomething(client, surv);
return surv.getId();
}
});
Which can be done by defining an Interface:
public interface ClientUpdate {
public void performUpdate(Client client, Surv surv);
}
Then, use this interface as a parameter to your method:
public Object updateStats() {
Becomes
public Object update(ClientUpdate updater) {
Then use it in your callable
tasks.add(new Callable<String>() {
public String call() throws Exception {
updater.performUpdate(client, surv);
return surv.getId();
}
});
Then implement it:
updateStats();
becomes:
update(new ClientUpdate() {
public void performUpdate(Client client, Surv surv) {
client.updateStats(surv).toString();
}
});
Similarly for updateDef();