ThreadLocal原理
2020-09-18 09:30:59 5 举报
ThreadLocal原理图
作者其他创作
大纲/内容
ThreadLocal原理剖析
得到obj2
Entry:{其他threadLocal}
调用threadLocal.set(obj1);
自带一个ThreadLocalMap实例:t1-map
调用threadLocal.get();
线程T2
ThreadLocal<Object> threadLocal = new ThreadLocal<>();
t1-map
Entry:{threadLocal:obj1}
得到obj1
调用threadLocal.set(obj2);
t2-map
线程T1
去自己的map中找key为threadLocal的Entry
......
自带一个ThreadLocalMap实例:t2-map
Entry:{threadLocal:obj2}
收藏
0 条评论
下一页