还是用图说话吧,对看图最简单。知道几个概念的关系,一切就顺理成章的记住了。
threadlocal related.png
Threadlocal.get>
Thread.threadLocals.getEntry>
ThreadLocalMap.table[ special i by threadlocal]>
retrun entry.value
ThreadLocal.set(value)>
Thread.threadLocals.set( threadlocal ,value)>
find or create entry(new entry(threadlocal,vale)) by special i (table[i])
网友评论