子线程 header值传递

1.查询父线程 header信息

RequestAttributes attributes = RequestContextHolder.getRequestAttributes();

2.调用子线程时写入header

Callable countryListCallable = () -> {
                RequestContextHolder.setRequestAttributes(attributes);
                return basicCountryService.getUserCountryByAccount(CommonConstants.ALL);
            };
            FutureTask menuListTask = new FutureTask<>(countryListCallable);
            executorService.submit(menuListTask);

你可能感兴趣的:(java)