import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
* @Description
* @Author
* @Date 2021/7/22 13:44
*/
@Slf4j
@Component
public class ThreadHandle {
// 最小分段大小
private static final int MIN_SEGMENT_SITZ = 5;
// 最大处理线程
private static final int MAX_THREAD = 5;
// springboot框架线程处理
@Autowired
private static Executor executor;
public static void main(String[] args) {
ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
List<User> userList = getUserList();
List<List<User>> partition = partition(userList);
// 结果列表
List<FutureTask<Integer>> resultList = new ArrayList<>()
多线程分段处理批量数据
最新推荐文章于 2023-12-23 15:58:45 发布