|
@@ -17,9 +17,6 @@ import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
|
-import java.util.concurrent.ExecutionException;
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @ClassName EasyExcelUtils
|
|
* @ClassName EasyExcelUtils
|
|
@@ -67,34 +64,6 @@ public class EasyExcelUtils {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public class CompletableFutureDemo6{
|
|
|
|
|
- public void main(String[] args) throws ExecutionException, InterruptedException{
|
|
|
|
|
- CompletableFuture<Integer> thenCombineResult = CompletableFuture.supplyAsync(() -> {
|
|
|
|
|
- System.out.println(Thread.currentThread().getName() + "\t" + "---come in 1");
|
|
|
|
|
- return 10;
|
|
|
|
|
- }).thenCombine(CompletableFuture.supplyAsync(() -> {
|
|
|
|
|
- System.out.println(Thread.currentThread().getName() + "\t" + "---come in 2");
|
|
|
|
|
- return 20;
|
|
|
|
|
- }), (x,y) -> {
|
|
|
|
|
- System.out.println(Thread.currentThread().getName() + "\t" + "---come in 3");
|
|
|
|
|
- return x + y;
|
|
|
|
|
- }).thenCombine(CompletableFuture.supplyAsync(() -> {
|
|
|
|
|
- System.out.println(Thread.currentThread().getName() + "\t" + "---come in 4");
|
|
|
|
|
- return 30;
|
|
|
|
|
- }),(a,b) -> {
|
|
|
|
|
- System.out.println(Thread.currentThread().getName() + "\t" + "---come in 5");
|
|
|
|
|
- return a + b;
|
|
|
|
|
- });
|
|
|
|
|
- System.out.println("-----主线程结束,END");
|
|
|
|
|
- System.out.println(thenCombineResult.get());
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- // 主线程不要立刻结束,否则CompletableFuture默认使用的线程池会立刻关闭:
|
|
|
|
|
- try { TimeUnit.SECONDS.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
* 校验
|
|
* 校验
|