说明
初次使用ForkAndJoin框架来操作task,总结一下调用任务的两种方式。
代码示例
任务
private static class TestTask extends RecursiveAction {
private String name;
private int a;
private Map<String, String> map;
public TestTask(String name, int a, Map<String, String> map) {
super();
this.name = name;
this.a = a;
this.map = map;
}
@SneakyThrows
@Override
protected void compute() {
System.out.println(name + " start");
long start = System.currentTimeMillis();
for (