首页 > 代码库 > ForkJoin框架使用逻辑

ForkJoin框架使用逻辑

public class ForkJoinLogic extends RecursiveTask<Integer> {
    private int interval;
    private int start;
    private int end;
    private String tableName;
    //实现业务逻辑的成员变量

    public ForkJoinLogic(int interval, int start, int end, String tableName) {
        this.interval = interval;
        this.start = start;
        this.end = end;
        this.tableName = tableName;
    }

    @Override
    protected Integer compute() {
        //flag是指间隔小于某个值
        boolean flag = false;
        if (flag) {
            /**
             * 分页逻辑
             * select * from tableName where ...>0 and ...<...
             *处理的业务逻辑,插入目标数据库
             */
            return 1;
        } else {
            /**
             * 对ResultSet进行fork
             *
             */
            return 1;
        }
    }
}

 

ForkJoin框架使用逻辑