1.线程池
package com.tigeriot.reportconfiguration.api.cloudplatform.reportconfiguration.datasetproperties.realtime.heatstation;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
public class Excuete {
public static void main(String[] args) throws InterruptedException, ExecutionException {
ThreadPoolExecutor executorService = new ThreadPoolExecutor(
2,
6,
10000,
TimeUnit.SECONDS,
new LinkedBlockingQueue<>(3)
);
ArrayList<Future<Integer>> futures = new ArrayList<>();
for (int i = 0; i < 8; i++) {
int finalI = i;
Callable<Integer> callable = new Callable<>() {
@Override
public Integer call() throws Exception {
TimeUnit.SECONDS.sleep(1L);
System.out.println(finalI);