BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(10); ThreadPoolExecutor threadPool = new ThreadPoolExecutor(2, 3, 3, TimeUnit.SECONDS, workQueue, r -> new Thread(r, "sync_export_pool_" + r.hashCode()), (r, executor) -> log.error("队列已满拒绝执行")); //异步调用,设置子线程共享 ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); //设置子线程共享 RequestContextHolder.setRequestAttributes(servletRequestAttributes, true); threadPool.submit(() -> { //do something log.info("当前线程:{}",Thread.currentThread().getName()); }); threadPool.shutdown();