mirror of
https://gitee.com/lakernote/easy-admin.git
synced 2026-09-03 13:37:29 +08:00
InheritableThreadLocalDemo
This commit is contained in:
@@ -39,7 +39,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* parentThreadName:pool-1-thread-9:8 pool-2-thread-4
|
||||
* </pre>
|
||||
*/
|
||||
public class InheritableThreadLocalDemoTrace2 {
|
||||
public class InheritableThreadLocalDemoTraceCopy {
|
||||
/**
|
||||
* 模拟tomcat线程池
|
||||
*/
|
||||
@@ -48,10 +48,11 @@ public class TraceCopyThreadPoolExecutor extends EasyAdminThreadPoolExecutor {
|
||||
Trace parentValue = TraceContext.trace();
|
||||
return () -> {
|
||||
if (parentValue == null) {
|
||||
log.info("ThreadLocal GToadContext is initialized");
|
||||
TraceContext.setTrace(new Trace());
|
||||
} else {
|
||||
// 复制 而不是引用
|
||||
log.trace("ThreadLocal childValue is initialized, parent: {}", parentValue);
|
||||
log.info("ThreadLocal childValue is initialized, parent: {}", parentValue);
|
||||
Trace trace = new Trace();
|
||||
trace.setDepth(parentValue.getDepth());
|
||||
trace.setSpans(parentValue.getSpans());
|
||||
|
||||
Reference in New Issue
Block a user