BAEL-612: used lambda instead of anonymous class
This commit is contained in:
parent
f970b1dbcf
commit
8f7559df5e
|
@ -1,6 +1,5 @@
|
||||||
package com.baeldung.concurrent.future;
|
package com.baeldung.concurrent.future;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
@ -13,12 +12,9 @@ public class SquareCalculator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Future<Integer> calculate(Integer input) {
|
public Future<Integer> calculate(Integer input) {
|
||||||
return executor.submit(new Callable<Integer>() {
|
return executor.submit(() -> {
|
||||||
@Override
|
Thread.sleep(1000);
|
||||||
public Integer call() throws Exception {
|
return input * input;
|
||||||
Thread.sleep(1000);
|
});
|
||||||
return input * input;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue