Код: Выделить всё
Map copyOfContextMap = MDC.getCopyOfContextMap();
ThreadContext threadContext = ThreadContext.builder()
.propagated(ThreadContext.ALL_REMAINING)
.cleared()
.build();
Runnable runnable = threadContext.contextualRunnable(() -> {
try {
MDC.setContextMap(copyOfContextMap);
latch.countDown();
for (int i = 0; i < 10; i++) {
log.info(i + ": Log inside async executor");
sleepQuietly();
}
} catch (Throwable e) {
log.error("Error during async execution", e);
}
});
executor.runAsync(runnable);
Подробнее здесь: https://stackoverflow.com/questions/798 ... edexecutor
Мобильная версия