static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 2, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(5000), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
public static void main(String[] args) {
List<Map<String, String>> list = new ArrayList<>();
// add 5000 次
list.add(new HashMap<>(16));
list.forEach(l -> CompletableFuture.runAsync(() -> {
System.out.println(l.get("xxx"));
System.out.println(l.get("yyy"));
// 又臭又长的代码 耗时 1s
}, threadPoolExecutor));
// 问:此时阻塞队列中任务内存占用主要来源于哪里?
// 是遍历 list 出来的每个元素对象的占用内存吗?
// 业务逻辑代码的长短 /复杂度会影响内存占用吗?
}