FastThreadLocal源码分析
Netty 的 FastThreadLocal 源码解析 该文中涉及到的 Netty 源码版本为 4.1.6。 Netty 的 FastThreadLocal 是什么 A special variant of ThreadLocal that yields higher access performance when accessed from a FastThreadLocalThread. Internally, a FastThreadLocal uses a constant index in an array, instead of using hash code and hash table, to look for a variable. Although seemingly very subtle, it yields slight performance advantage over using a hash table, and it is useful when accessed frequently. To take advantage of this thread-local variable, your thread must be a FastThreadLocalThread or its subtype. By default, all threads created by DefaultThreadFactory are FastThreadLocalThread due to this reason. Note that the fast path is only possible on threads that extend FastThreadLocalThread, because it requires a special field to……