Merge pull request #1075 from felipe-gdr/master

BAEL-612: used lambda instead of anonymous class
This commit is contained in:
pedja4 2017-01-31 09:42:25 +01:00 committed by GitHub
commit 8a5600cf6e
1 changed files with 4 additions and 8 deletions

View File

@ -1,6 +1,5 @@
package com.baeldung.concurrent.future;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@ -13,12 +12,9 @@ public class SquareCalculator {
}
public Future<Integer> calculate(Integer input) {
return executor.submit(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
Thread.sleep(1000);
return input * input;
}
});
return executor.submit(() -> {
Thread.sleep(1000);
return input * input;
});
}
}