大数据量查询
代码思路:
1:拆分大数据(分页),例如多条数据根据合理数据拆分,推荐拆分集合代码com.google.common.collect.Lists.partition(list,2000)
将list集合按指定长度进行切分,返回新的List<List<??>>集合
package test;
import com.google.common.collect.Lists;
import org.junit.Test;
import java.util.List;
/**
* Created by Administrator on 2018/10/28/028.
*/
public class testList {
@Test
public void test(){
List<Integer> numList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8);
List<List<Integer>> lists=Lists.partition(numList,3);
System.out.println(lists);//[[1, 2, 3], [4, 5, 6], [7, 8]]
}
}
2: 利用spring的线程池
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
3:利用java中的Callable来接受返回数据。